Spring 连接oracle 数据源配置方式

spring自带的数据源(DriverManagerDataSource)

xml文件中内容如下:

<bean id=”dataSource”
class=”org.springframework.jdbc.datasource.DriverManagerDataSource”>
<property name=”driverClassName” value=”${jdbc.driverClassName}” />
<property name=”url” value=”${jdbc.url}” />
<property name=”username” value=”${jdbc.username}” />
<property name=”password” value=”${jdbc.password}” />
</bean>

 

DBCP数据源

<bean id=”dataSource” class=”org.apache.commons.dbcp2.BasicDataSource”
destroy-method=”close”>

~~~~~

 

外部属性文件中具体定义数据库连接配置 继续阅读“Spring 连接oracle 数据源配置方式”

The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced from required .class files

The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced from required .class files

缺少包

解决方法:
导入spring.transaction-3.0.5.jar 包就好了。
新版本包名变了,如下:

继续阅读“The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced from required .class files”

Spring 问题 Exception in thread “main” org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file

情報: Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@2957a4: startup date [Tue Nov 15 15:17:09 CST 2016]; root of context hierarchy [火 11 15 15:17:09 CST 2016]
情報: Loading XML bean definitions from file [D:\workspace\SpringApp2\SpringTest.xml] [火 11 15 15:17:09 CST 2016]
Exception in thread “main” org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file

 

缺少必要的包

spring-aop-4.3.4.RELEASE.jar

Spring 问题 Exception in thread “main” org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 12 in XML document

Exception in thread “main” org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 12 in XML document

其中xml文件有如下内容:

<context:component-scan base-package=”spring.test” />

原因

<beans xmlns 内容缺少东西

如下:

继续阅读“Spring 问题 Exception in thread “main” org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 12 in XML document”