1. 修改package内容为war文件
<packaging>war</packaging>
2.配置servlet
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
3.移除嵌入式tomcat插件
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
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;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@MapperScan("com.example.mapper")//与dao层的@Mapper二选一写上即可(主要作用是扫包)
public class UserPerson4Application extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(UserPerson4Application.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// 注意这里要指向原先用main方法执行的Application启动类
return builder.sources(UserPerson4Application.class);
}
}
5.右键项目->properties->Maven删除pom.xml,apply and close
6.右键项目,clean
6.右键项目,Maven build
7.Goals处填package,Skip Tests前面打勾
8.JRE选项里面选择JDK,Apply->Run
9.生成的war包在项目下的target目录里面
还没有评论,来说两句吧...