我试图整合spring和mybatis。
JDK:1.8
运行我的测试:
@Test
public void testFindUserById() throws Exception{
UserMapper userMapper=(UserMapper)applicationContext.getBean("userMapper");
User user=userMapper.findUserById(1);
System.out.println(user);
}
java.lang.IllegalAccessError: org.apache.commons.dbcp.DelegatingPreparedStatement.isClosed()Z
弹簧配置文件:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/custom?useSSL=false" />
<property name="username" value="root" />
<property name="password" value="qqwe5631652" />
<property name="maxIdle" value="5" />
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:SqlMapConfig.xml" />
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="mapper" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
<bean id="userDao" class="dao.UserDaoImpl">
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>
</beans>
file's structure all of ‘.jar’
这是关于权威的java.lang.IllegalAccessError
?我不知道
我将commons-dbcp-1.2.1.jar
改成commons-dbcp-1.4.jar
,现在好了!
是的,你的解决方案是正确的。如果您查看DelegatingPreparedStatement.isClosed()javadoc,您可以看到此方法受到保护,因此您身边调用此方法的任何尝试都将以IllegalAccessException结束,因为您没有权限执行此操作。该库的较新版本已将此版本公之于众