zoukankan      html  css  js  c++  java
  • 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的依赖
  • 相关阅读:
    洛谷 P2108 学英语
    洛谷 P1010 幂次方
    洛谷 P1101 单词方阵
    洛谷 P1217 [USACO1.5]回文质数 Prime Palindromes
    洛谷 P1553 数字反转(升级版)
    hdu_1348_Wall(凸包)
    hdu_1392_Surround the Trees(凸包)
    hdu_1115_Lifting the Stone(求多边形重心)
    Codeforces Round #354 (Div. 2)_Vasya and String(尺取法)
    hdu_1558_Segment set(并查集+计算几何)
  • 原文地址:https://www.cnblogs.com/y654063871/p/7049425.html
Copyright © 2011-2022 走看看