Mac下Mybatis + Intellij 编译报错SqlSessionTemplate cannot be resolved to a type
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</pre>
在Eclipse下编译没有问题,可以成功运行项目,但是Intellij下出错。 项目运行环境设置了jdk1.8.0_51,tomcat也是。 用gradle导入了MyBatis相关jar包 mybatis3.2.6 和 mybatis-spring1.2.2
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
看看xml文件在编译的时候,是否正确被发布到运行目录下
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 1. Data Source -->
<import resource="classpath:config/datasource.xml"/>
<!-- 2. SQL session factory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath:mybatis-mapper/**/*.xml" /> <!-- Mapper xml -->
</bean>
<!-- 3. Instantiate Mapper -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.xtuer.dao.mybatis.mapper" />
</bean>
</beans>