工作生活

启动类报错

2019-07-08  本文已影响0人  Quillagua

启动类SpringBootServletInitializer标红报错,导入的类不对。
原因:
Spring Boot 部署到 Tomcat 中去启动时需要在启动类添加SpringBootServletInitializer,2.0 和 1.0 有区别。
解决方案:

package com.dudu;

import com.dudu.util.MyMapper;
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.servlet.support.SpringBootServletInitializer;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.sql.DataSource;

@SpringBootApplication
//启注解事务管理
@EnableTransactionManagement // 启注解事务管理,等同于xml配置方式的 <tx:annotation-driven />
@MapperScan(basePackages = "com.dudu.dao", markerInterface = MyMapper.class)

public class Application extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(Application.class);
}

public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
}

}

上一篇下一篇

猜你喜欢

热点阅读