application Configuration Class:
@SpringBootApplication public
class Servletinitializer extends Springbootservletinitializer {
@Override
protected Springapplicationbuilder Configure (Springapplicationbuilder application) {
return Application.sources (Servletinitializer.class);
}
public static void Main (string[] args) throws Exception {
springapplication.run (servletinitializer.class, args);
}
}
Note : The startup class is best placed in the outermost layer of the project's package, so that you can scan to all package paths.
Controller:
@Controller public
class Bootcontroller {
@RequestMapping ("/")
@ResponseBody
String Home () {
return "Hello world!";
}
public static void Main (string[] args) throws Exception {
springapplication.run (bootcontroller.class, args);
}
}
Pom
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:s chemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <groupId>cn.creditease.springboot</groupId> < Artifactid>springboot</artifactid> <packaging>war</packaging> <version>1.0</ version> <name>maven webapp</name> <url>http://maven.apache.org</url> <propertie S> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project_charset> Utf-8</project_charset> <maven.compiler.source>1.7</maven.compiler.source> < Maven.compiler.target>1.7</maven.compiler.target> <tomcat.version>7.0.67</tomcat.version> & Lt;/properties> <parent> <groupid>org.springframework.booT</groupid> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.1.rel ease</version> </parent> <dependencies> <dependency> <groupid>or G.springframework.boot</groupid> <artifactId>spring-boot-starter-web</artifactId> &L
T;/dependency> <dependency> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope>
</dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> &L t;/dependency> </dependencies> <repositories> <repository> <i d>spring-releases</id> <name>spring releases</name> <url>http://repo.spring.io/libs-rel
Ease-local</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </project>
Note: If you want to start with TOMCAT7, you need to develop your Tomcat version number.
Server:
port:8080
spring.mvc.view.prefix:/web-inf/jsp/
spring.mvc.view.suffix:. jsp
Project