Springboot与jdk1.6开发遇到的问题-开发工具idea

springboot2.0要求要jdk1.8版本以上,所我们不能用springboot2.X系列

一开始用了2.0.0,发现并jdk1.6并不能用springboot2.0.0,所以我用了springboot1.4.5,1.4.5只支持Tomcat7,以下项目pom依赖引入

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.5.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

但是还有加以下两个依赖,不然会报错

<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat-juli</artifactId>
    <version>${tomcat.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jetty</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.eclipse.jetty.websocket</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>

在这个时候我又引入mybatis-spring-boot-starter 1.3.2来使用mybatis,但是发现不能找到mapper实例,报如下错误,一顿错误狂找,没有发现问题

ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dsmController': Unsatisfied dependency expressed through field 'signedMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'signedMapper' defined in file [F:\Users\Because of you\ide\driverstudymanager\target\classes\com\qy\dsm\mapper\SignedMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration$$EnhancerBySpringCGLIB$$81f3911e]: Constructor threw exception; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'java.lang.Object' available: expected single matching bean but found 4: &signedMapper,systemEnvironment,contextParameters,contextAttributes

我觉得是版本配套问题吧,我把mybatis-spring-boot-starter 1.3.2换成mybatis-spring-boot-starter 1.1.1,结果tm神奇的可以了,能用自动注入实例了。

使用mybatis *Mapper.xml这种方式一定注意xml文件的位置,application.yml配置一定要正确,不然会包Invalid bound statement (not found),关联不到xml文件

mybatis:
  mapper-locations:classpath:mybatis/mapper/*.xml
  type-aliases-package: 
  config-location:classpath:mybatis/mybatis-config.xml

反正jdk1.6使用springboot坑挺多的,咱也不知道,咱也不敢问啊!

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值