How to start maven project
- Run the startup class directly
- Run with mvn spring-boot:run
- After packaging into a jar package, use java -jar xxx.jar to run
- After packaging into a war package, use java -jar xxx.war to run
Method 1: Run the startup class directly
方式2:mvn spring-boot:run
The pom.xml file of the springboot project contains by default:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
So you can use the following method to run graphically.
Click on the small window in the lower left corner, and then Mavne Projects will appear on the right
. Find your springboot project in Mavne Projects, and then click spring-boot:run
or run with the command line:
first enter springboot Project directory, and then run the mvn spring-boot:run command
Pack it into a jar package and run
The default packaging form in the pom.xml file of the springboot project is a jar package
<packaging>jar</packaging>
The packaging method is as follows:
- Graphical packaging
- Command line packaging
Enter the springboot project directory, and then run the mvn package command to
run the jar package:
Maven is packaged in the target directory by default, enter the target directory of the springboot project, and then run the java -jar xxx.jar command to run the program.
Pack it into a war package and run
Modify the packaging form in the pom.xml file of the springboot project to be a war package
<packaging>war</packaging>
The subsequent packaging method and running method are similar to the packaged jar package operation, the only difference is that the running command is in the form of java -jar xxx.war.
Gradle project startup method
-
java -jar xxx.jar
-
Run as "java Application"
-
gradlew bootRun, run with the version of gradle wrapper;
-
gradle bootRun, run with the local gradle version.