springboot整合mybatis 启动报错

jackps22008 2018-08-07 02:18:24

java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.mybatis.spring.annotation.MapperScan.factoryBean()
at java.lang.reflect.Method.getDefaultValue(Method.java:612) ~[na:1.8.0_131]
at sun.reflect.annotation.AnnotationType.<init>(AnnotationType.java:132) ~[na:1.8.0_131]
at sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:85) ~[na:1.8.0_131]
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:266) ~[na:1.8.0_131]
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120) ~[na:1.8.0_131]
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72) ~[na:1.8.0_131]
at java.lang.Class.createAnnotationData(Class.java:3521) ~[na:1.8.0_131]
at java.lang.Class.annotationData(Class.java:3510) ~[na:1.8.0_131]
at java.lang.Class.getAnnotations(Class.java:3446) ~[na:1.8.0_131]
at org.springframework.core.type.StandardAnnotationMetadata.<init>(StandardAnnotationMetadata.java:70) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition.<init>(AnnotatedGenericBeanDefinition.java:58) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.doRegisterBean(AnnotatedBeanDefinitionReader.java:216) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:145) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.register(AnnotatedBeanDefinitionReader.java:135) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:158) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:135) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:127) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.load(SpringApplication.java:704) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:393) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:328) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at com.example.TestDemoApplication.main(TestDemoApplication.java:12) [classes/:na]

springboot版本 2.0.4.RELEASE mybatis版本 3.4.6 mybatis-spring版本 1.3.2
...全文
1296 33 打赏 收藏 转发到动态 举报
写回复
用AI写文章
33 条回复
切换为时间正序
请发表友善的回复…
发表回复
答 案 2019-05-14
  • 打赏
  • 举报
回复
删除maven库重新下载jar包可破!
q619751941 2018-10-22
  • 打赏
  • 举报
回复
楼主,问题有没有解决 我也遇到相同的问题,spring-boot版本2.0.6,mybatis-spring-boot-starter版本1.3.2
东平王北星 2018-08-22
  • 打赏
  • 举报
回复
@MapperScan("com.example.dao") 改成tk.mybatis包下的@MapperScan
老王就是我 2018-08-21
  • 打赏
  • 举报
回复
引用 33 楼 jackps22008 的回复:
[quote=引用 30 楼 qq_22899047 的回复:]
[quote=引用 29 楼 jackps22008 的回复:]
[quote=引用 28 楼 qq_22899047 的回复:]
Tomcat版本有没有错?

springboot不是内置tomcat吗[/quote]
可以引用外部的tomcat,还有,注意一下jdk版本,换不同的版本试一下[/quote]
springboot版本降到1.X版本就正常 不知道什么原因 2.X版本就报错[/quote]
那可能版本不兼容,尝试更新一下ibatis版本或者降低sb版本
jackps22008 2018-08-20
  • 打赏
  • 举报
回复
引用 30 楼 qq_22899047 的回复:
[quote=引用 29 楼 jackps22008 的回复:]
[quote=引用 28 楼 qq_22899047 的回复:]
Tomcat版本有没有错?

springboot不是内置tomcat吗[/quote]
可以引用外部的tomcat,还有,注意一下jdk版本,换不同的版本试一下[/quote]
springboot版本降到1.X版本就正常 不知道什么原因 2.X版本就报错
jackps22008 2018-08-20
  • 打赏
  • 举报
回复
引用 24 楼 jackps22008 的回复:
[quote=引用 20 楼 xiaoliu598906167 的回复:]


你的springboot是什么版本的[/quote]
springboot版本是2.0.4.RELEASE
xiaou66 2018-08-20
  • 打赏
  • 举报
回复
有没有解决
我也遇到相同的问题但是把spring-boot版本降到2.0.1就可以了
老王就是我 2018-08-10
  • 打赏
  • 举报
回复
引用 29 楼 jackps22008 的回复:
[quote=引用 28 楼 qq_22899047 的回复:]
Tomcat版本有没有错?

springboot不是内置tomcat吗[/quote]
可以引用外部的tomcat,还有,注意一下jdk版本,换不同的版本试一下
jackps22008 2018-08-10
  • 打赏
  • 举报
回复
引用 28 楼 qq_22899047 的回复:
Tomcat版本有没有错?

springboot不是内置tomcat吗
老王就是我 2018-08-09
  • 打赏
  • 举报
回复
Tomcat版本有没有错?
梨花剑君 2018-08-09
  • 打赏
  • 举报
回复
把mybatis的依赖注释掉。在pom.xml中。
jackps22008 2018-08-09
  • 打赏
  • 举报
回复
引用 21 楼 lihuajianjun 的回复:
把mybatis的依赖注释掉。在pom.xml中。

mybatis依赖去掉也不行
jackps22008 2018-08-09
  • 打赏
  • 举报
回复
引用 20 楼 xiaoliu598906167 的回复:


你的springboot是什么版本的
flybirding10011 2018-08-09
  • 打赏
  • 举报
回复
<div><span>这里是一个div加span</span></div>
北九道 2018-08-08
  • 打赏
  • 举报
回复
把mybatis的依赖注释掉。在pom.xml中。
jackps22008 2018-08-08
  • 打赏
  • 举报
回复
项目结构:

jackps22008 2018-08-08
  • 打赏
  • 举报
回复
引用 3 楼 ren814 的回复:
[quote=引用 2 楼 jackps22008 的回复:]
[quote=引用 1 楼 ren814 的回复:]
org.mybatis.spring.annotation.MapperScan

com.example.TestDemoApplication.main(TestDemoApplication.java:12)
,然后我猜的,第一句是在spring boot里面配置mybatis的mapperscan扫描的时候,有毛病,然后猜测你的TestDemoApplication应该就是参数配置文件,包括启动的把,觉得,应该是你的扫描mapper的那个注解有问题。
@MapperScan("com.winter.mapper")//将项目中对应的mapper类的路径加进来就可以了

启动类上面已经加过了@MapperScan("com.example.dao") [/quote]
可以贴上来?连import 包[/quote]

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

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<!-- 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
<!-- alibaba的druid数据库连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.9</version>
</dependency>
</dependencies>



package com.example;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("com.example.dao")
public class TestDemoApplication {

public static void main(String[] args) {
SpringApplication.run(TestDemoApplication.class, args);
}
}
嘿科 2018-08-08
  • 打赏
  • 举报
回复

嘿科 2018-08-08
  • 打赏
  • 举报
回复
我用的idea 配置的 没有出问题。
北九道 2018-08-08
  • 打赏
  • 举报
回复
引用 16 楼 qingtingnayongheng 的回复:
[quote=引用 11 楼 ren814 的回复:]
[quote=引用 10 楼 qingtingnayongheng 的回复:]
这个spring boot 各种整合各种报错,整合MAVEN 报错,发布tomcat也报错,配置redis 也出错。反正我是头发掉了很多。 买来的东西 不好整。


有这么厉害吗?我觉得还好吧,前段时间刚整合过一遍,数据库,静态资源,mvc什么的,就是之前一直用eclipse,然后这个IDEA工具很不熟悉,里面闹出来很多笑话。其他的我感觉还好。[/quote]

我一直用eclipse ,IDEA 感觉黑乎乎的,视觉上就不爽。[/quote]
额,这个都可以设置的啊,我的界面白色的,eclipse也可以设置,背景色,代码颜色,包括方法颜色,变量颜色,都可以设置。只是看到有人讲到做这个springboot很好用, 然后就试着用了,当然了,开始用着肯定没有eclipse舒服
加载更多回复(13)

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧