maven packaged into a jar
select maven project with the idea of quickly generating projects and packaged into a jar, as well as their own group Artifact definition, then click Next to have been completed.
Easily build a controller, start the project, with the corresponding address of the default port of 8080 as well as in the figure below, you can have access to
M click on the right button, find the package to perform, or to perform mvn package in the following terminal
The following diagram, the package proved successful
According to the chart to find the path after compiling, you can perform right after the selected
Similarly, modifications packaged in WAR pom.xml way, perform the same steps described above, the success of the packer below
Directly run java -jar demo-0.0.1-SNAPSHOT.war
below, starting with the results of the jar is the same way
Here are some ways gradle packaged
for convenience with commands to turn the items maven gradle projects
performed in the root directory: gradle init --type pom
The following figure generated gradle related things, manually delete the relevant maven
restart the idea into the project, there will be a prompt to let you build, the background will be shown below after clicking bulid
During the normal start of the project, you can still start a successful return to the current project, but also the normal access
And then re-execute the root of the terminal project
gradle Build
posted below gradle jar packed configuration and war, are generated by default idea
jar:
buildscript {
ext {
springBootVersion = '2.1.0.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
war:
buildscript {
ext {
springBootVersion = '2.1.0.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
Java -jar is also performed corresponding to jar or war