Quick Start是这样写的
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
估计是为了让大家很快上手,但是问题马上就来了,如何发布呀
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
这就是必须的了,这个是使用java -jar的方式执行时需要的。
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!--jetty 插件,mvn jetty:run -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.7.v20160115</version>
<configuration>
<webApp>
<contextPath>/</contextPath>
<descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor>
</webApp>
<stopKey>exit</stopKey>
<stopPort>9091</stopPort>
<webAppSourceDirectory>${project.basedir}/src/main/webapp</webAppSourceDirectory>
<scanIntervalSeconds>0</scanIntervalSeconds>
<httpConnector>
<port>8087</port>
</httpConnector>
</configuration>
</plugin>
<!-- tomcat 插件,mvn tomcat:run -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<path>/</path>
<port>8080</port>
<uriEncoding>UTF-8</uriEncoding>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
</configuration>
</plugin>
</plugins>
这两个选择其中之一就行,是maven的发布方式。还有进入pom文件的目录输入 mvn spring-boot:run启动,此命令是利用spring boot框架内置的tomcat运行spring boot开发的web应用。