千家信息网

SpringBoot2.1.6整合遇见的问题有哪些

发表于:2025-02-05 作者:千家信息网编辑
千家信息网最后更新 2025年02月05日,这篇文章将为大家详细讲解有关SpringBoot2.1.6整合遇见的问题有哪些,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。项目配置pom文件:4.0
千家信息网最后更新 2025年02月05日SpringBoot2.1.6整合遇见的问题有哪些

这篇文章将为大家详细讲解有关SpringBoot2.1.6整合遇见的问题有哪些,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

项目配置pom文件:

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
www.3wd.top
springBoot
springBoot-1.0


org.springframework.boot
spring-boot-starter-parent
2.1.6.RELEASE


2.1.0
mysql
mysql-connector-java
8.0.16
1.2.58
1.1.18
1.0.2
2.1.5
1.2.12
1.3.7
28.0-jre






org.springframework.boot
spring-boot-starter-web



org.mybatis.spring.boot
mybatis-spring-boot-starter
${mybatis.spring.boot}


tk.mybatis
mapper-spring-boot-starter
${tk.mybatis.version}


com.github.pagehelper
pagehelper-spring-boot-starter
${com.github.pagehelper.version}



org.mybatis.generator
mybatis-generator-core
${org.mybatis.generator.version}
compile
true



org.springframework.boot
spring-boot-starter-aop



org.springframework.boot
spring-boot-starter-test
test



com.alibaba
druid-spring-boot-starter
${alibaba.druid.version}



${jdbc.driver.groupId}
${jdbc.driver.artifactId}
${jdbc.driver.version}


org.springframework.boot
spring-boot-starter-jdbc


org.springframework.boot
spring-boot-starter-freemarker




javax.persistence
persistence-api
${javax.persistence.api}


org.apache.commons
commons-lang3


com.google.guava
guava
${com.google.guava.version}



war

top


src/main/resources
true




org.springframework.boot
spring-boot-maven-plugin


org.mybatis.generator
mybatis-generator-maven-plugin

${basedir}/src/main/resources/generator/generatorConfig.xml
true
true



maven-resources-plugin

UTF-8



org.apache.maven.plugins
maven-surefire-plugin

true



问题一:

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1e0721ac] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@196918e2] will not be managed by Spring

产生原因:没有配置事物控制

解决办法:在启动类中添加@EnableTransactionManagement 和实现类中添加@Transactional 声明事务就可以了,

问题二:NoSuchMethodException: tk.mybatis.mapper.provider.base.BaseInsertProvider.()

产生原因:原因是你集成使用tk.mybatis 的包,dao接口中导入的都是k.mybatis有关的包,而Application 启动类中@MapperScan注解 导入的包是org.mybatis.spring.annotation.MapperScan。造成k.mybatis这个包中初始化失败

解决办法:Application 启动类中@MapperScan注解 导包使用 import tk.mybatis.spring.annotation.MapperScan; 这个包扫描Mapper接口

问题三:使用@Slf4j注解中 log 报错

产生原因:可能你使用的开发工具没有集成lombok.jar

解决办法:复制你项目中依赖lombok.jar 这个版本的jar。这里以eclipse为例:

把这个lombok.jar复制到你eclipse平级目录中,然后在eclipse.ini加上 -javaagent:D:\eclipse-jee-2019-06\lombok.jar ,重新打开eclipse即可

lombok.jar : 下载地址 https://www.projectlombok.org/all-versions

关于SpringBoot2.1.6整合遇见的问题有哪些就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

0