<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<!--自动检测项目中的 main 函数-->
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
浏览器访问结果如下:
<packaging>war</packaging>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--tomcat启动器依赖范围-->
<scope>provided</scope>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>hello</warName>
</configuration>
</plugin>
package cn.fpl;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class SpringbootHelloworldApp extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(SpringbootHelloworldApp.class);
}
public static void main(String[] args) {
SpringApplication.run(SpringbootHelloworldApp.class, args);
}
}
可以发现,运行的war包可以通过自定义的url名字进行访问,服务器端口并不是在application.yml中配置的端口8090,而是本机的tomcat服务器的端口8080