我已经从SpringBoot应用程序创建了一个war文件。 (Spring Initializer,嵌入式Tomcat,Thymeleaf模板引擎)。根/重定向到欢迎页面
这是主要课程:
@Profile("war")
@Import({SecurityConfig.class ,PersistenceConfig.class})
@SpringBootApplication
public class BookCloudApplicationWar extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(BookCloudApplicationWar.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(BookCloudApplicationWar.class, args);
}
}
这是我的application.properties
server.contextPath=/book
server.port=8080
这是tomcat控制台,没有错误:
Mar 16, 2017 7:50:29 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/bookcloud-0.0.1-SNAPSHOT.war
但我有404访问
http://149.142.221.107:8080/bookcloud-0.0.1-SNAPSHOT/
或
http://149.142.221.107:8080/bookcloud-0.0.1-SNAPSHOT/book
或
http://149.142.221.107:8080/book
或
http://149.142.221.107:8080/book/book
并且控制台中没有错误
这里是战争中的MANIFEST.MF
Manifest-Version: 1.0
Implementation-Title: bookcloud
Implementation-Version: 0.0.1-SNAPSHOT
Archiver-Version: Plexus Archiver
Built-By: nunito
Implementation-Vendor-Id: com.tdk
Spring-Boot-Version: 1.5.2.RELEASE
Implementation-Vendor: Pivotal Software, Inc.
Main-Class: org.springframework.boot.loader.WarLauncher
Start-Class: com.tdk.BookCloudApplicationWar
Spring-Boot-Classes: WEB-INF/classes/
Spring-Boot-Lib: WEB-INF/lib/
Created-By: Apache Maven 3.3.3
Build-Jdk: 1.8.0_77
Implementation-URL: http://projects.spring.io/spring-boot/bookcloud/
并且在tomcat managet应用程序界面中,似乎这个应用程序正在运行bookcloud-0.0.1-SNAPSHOT /