pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0
</modelVersion>
<groupId>springboot-jsp-war
</groupId>
<artifactId>springboot-jsp-war
</artifactId>
<packaging>war
</packaging>
<name>springboot-jsp :: 整合 JSP-WAR 案例
</name>
<parent>
<groupId>org.springframework.boot
</groupId>
<artifactId>spring-boot-starter-parent
</artifactId>
<version>1.5.10.RELEASE
</version>
</parent>
<properties>
<mybatis-spring-boot>1.2.0
</mybatis-spring-boot>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot
</groupId>
<artifactId>spring-boot-starter-freemarker
</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot
</groupId>
<artifactId>spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot
</groupId>
<artifactId>spring-boot-starter-test
</artifactId>
<scope>test
</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot
</groupId>
<artifactId>mybatis-spring-boot-starter
</artifactId>
<version>${mybatis-spring-boot}
</version>
</dependency>
<dependency>
<groupId>mysql
</groupId>
<artifactId>mysql-connector-java
</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed
</groupId>
<artifactId>tomcat-embed-jasper
</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet
</groupId>
<artifactId>javax.servlet-api
</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet
</groupId>
<artifactId>jstl
</artifactId>
</dependency>
<dependency>
<artifactId>spring-boot-starter-tomcat
</artifactId>
<groupId>org.springframework.boot
</groupId>
<scope>provided
</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}
</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot
</groupId>
<artifactId>spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
修改启动类,设置启动配置
package org.spring.springboot;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
/**
* Spring Boot 应用启动类
*
* @author colg
*/
@SpringBootApplication
@MapperScan(
"org.spring.springboot.dao")
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
protected SpringApplicationBuilder
configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
}
打包运行
http://localhost:8080/springboot-jsp-war/api/city/1 必须使用tomcat8.x部署