启动类报错

作者: Quillagua | 来源:发表于2019-07-08 17:24 被阅读0次

    启动类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);
    }
    

    }

    相关文章

      网友评论

        本文标题:启动类报错

        本文链接:https://www.haomeiwen.com/subject/xgerhctx.html