spring-boot随笔

配置了spring-boot-starter-web的依赖后,会自动添加tomcat和spring mvc的依赖,那么spring boot 会对tomcat和spring mvc进行自动配置

 

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>


使用eclipse运行mvn spring boot项目时
  在当前项目目录下,在地址栏输入cmd,进入命令提示行,输入mvn clean install --> mvn spring-boot:run执行

使用idea运行时
  点击导航栏的run,如果没有配置过的话,点击Run.. --> 左上角+号,在右侧选择项目目录
  下次直接点击该运行即可

maven 跳过测试
mvn install -Dmaven.test.skip=true

--------------------------------------------------------------------------------------------------------
  1. 2017-05-11 16:15:32.410 [main] INFO  o.a.catalina.core.StandardService - Stopping service Tomcat   
  2. 2017-05-11 16:15:32.457 [main] INFO  o.s.b.a.l.AutoConfigurationReportLoggingInitializer -   
  3.   
  4. Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.   
  5. 2017-05-11 16:15:32.726 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter -   
  6.   
  7. ***************************  
  8. APPLICATION FAILED TO START  
  9. ***************************  
  10.   
  11. Description:  
  12.   
  13. Field xxxMapper in XXXX required a bean of type 'XXXMapper' that could not be found.  
  14.   
  15.   
  16. Action:  
  17.   
  18. Consider defining a bean of type 'XXXMapper' in your configuration.  
  19.    
  20.   
  21. Process finished with exit code 1  


 

 

使用spring boot或Spring cloud配置mybatis,我用的是mybatis-generator插件自动生成实体和DAO层以及XML文件,最后启动时报了上面的错误,解决方法是在你的启动程序上加上这么一句:

 

@MapperScan("xxx.mapper")
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
在Application类的上面,也就是配置你的mapper的路径。

需要再maven中加入 mybatis的依赖
posted @ 2017-06-19 16:45  一笑奈何莫洛兮  阅读(390)  评论(0编辑  收藏  举报