A, eclipse springboot fight the war package
1. pom.xml configuration file
<packaging>war</packaging>
<!-- 配置servlet,打war包时放开 --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> </dependency>
<-! Remove embedded tomcat plug-in, open the package when playing war -> <Exclusions> <Exclusion> <groupId> org.springframework.boot </ groupId> <artifactId> the Spring-the Boot-Starter-tomcat </ the artifactId> </ Exclusion> </ Exclusions>
<resources> <-! When you package will copy the page file to the META-INF directory -> <Resource> <-! resource files in the specified directory which plug-in processing resources -> <Directory> src / main / the webapp </ directory> <-! Note that this must be placed in this directory can be accessed -> <targetPath> META-INF / Resources </ targetPath> <Includes> <the include> ** / ** </ the include> </ Includes> </ Resource> <Resource> <Directory> the src / main / Resources </ Directory> <Includes> <the include> * * / ** </ the include> </ Includes> <Filtering>false</filtering> </resource> <resource> <directory>src/main/java</directory> <excludes> <exclude>**/*.java</exclude> </excludes> </resource> </resources>
2. Modify springboot startup class, add @EnableScheduling notes, inheritance SpringBootServletInitializer class, configure new method
@EnableScheduling public class DemoApplication the extends SpringBootServletInitializer { public static void main (String [] args) { SpringApplication.run (DemoApplication. Class , args); } / ** * This method is to add * / @Override protected SpringApplicationBuilder Configure (SpringApplicationBuilder Builder) { // Note that for a start point Application class previously executed by the main method return builder.sources (DemoApplication. class ); } }
3. Modify the project Maven
Right project properties
4. Right Project Run As -> Maven clean
5. Right Project Run As -> Maven build ...
6. main tab, Goals fill in the package, check the Skip Tests
7. JRE tab, choose JDK can not be here with JRE, first Apply and then Run
jre the eclipse default is not configured jdk small can be so selected partners
8. targer found war package
Two, war package runs in Tomcat
1. say war package on Tomcat webapps folder
2. Modify conf folder server.xml file
Add <Context> in <Host>, because the need to join the project name (each address will be added) in the path when running Tomcat, so Tomcat directly to the default path instead of the path of the project
I tried other ways, but not very good with friends, if there is a better way to welcome message, thank you!
<! - Tomcat modify the default access path -> <Context path = "" docBase = "/ project name" reloadable = "true" />
3. Start Tomcat
4. Access Project