开发者社区> 问答> 正文

Mac下Mybatis + Intellij 编译报错SqlSessionTem?报错

Intellij导入Eclipse的web工程,编译报错

Caused by: java.lang.Error: Unresolved compilation problems: 
	The import org.mybatis cannot be resolved
	SqlSessionTemplate cannot be resolved to a type
	SqlSessionTemplate cannot be resolved to a type
	SqlSessionTemplate cannot be resolved to a type
	SqlSessionTemplate cannot be resolved to a type
	SqlSessionTemplate cannot be resolved to a type

	at com.sunlord.core.db.BaseMyBatisDao.<init>(BaseMyBatisDao.java:19)
	at com.sunlord.core.db.GenericDao.<init>(GenericDao.java:18)
	at com.sunlord.platform.dao.admin.WhatsNewDao.<init>(WhatsNewDao.java:11)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
	... 62 more



在Eclipse下编译没有问题,可以成功运行项目,但是Intellij下出错。
项目运行环境设置了jdk1.8.0_51,tomcat也是。
用gradle导入了MyBatis相关jar包 mybatis3.2.6 和 mybatis-spring1.2.2



展开
收起
爱吃鱼的程序员 2020-06-10 13:49:39 529 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    看看xml文件在编译的时候,是否正确被发布到运行目录下

    <spanstyle="font-family:Consolas,'BitstreamVeraSansMono','CourierNew',Courier,monospace;background-color:#FFFFFF;"><spanstyle="background-color:#FF9900;">org.mybatis.spring.<spanstyle="font-family:Consolas,'BitstreamVeraSansMono','CourierNew',Courier,monospace;background-color:#FF9900;">SqlSessionTemplate<spanstyle="background-color:#FF9900;">

    <spanstyle="font-family:Consolas,'BitstreamVeraSansMono','CourierNew',Courier,monospace;background-color:#FFFFFF;"><spanstyle="background-color:#FF9900;">

    <preclass="brush:xml;toolbar:true;auto-links:false;"><?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd"><!--1.DataSource--><importresource="classpath:config/datasource.xml"/><!--2.SQLsessionfactory--><beanid="sqlSessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean"><propertyname="dataSource"ref="dataSource"/><propertyname="mapperLocations"value="classpath:mybatis-mapper/**/*.xml"/><!--Mapperxml--></bean><!--3.InstantiateMapper--><beanclass="org.mybatis.spring.mapper.MapperScannerConfigurer"><propertyname="basePackage"value="com.xtuer.dao.mybatis.mapper"/></bean></beans>




    2020-06-10 13:49:55
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Java Spring Boot开发实战系列课程【第6讲】:Spring Boot 2.0实战MyBatis与优化(Java面试题) 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载