【发布时间】:2015-03-14 11:35:07
【问题描述】:
我正在制作一个简单的 spring 应用程序。我已经在我的另一台计算机上对此进行了编程,并决定从头开始重新编写以将其真正提交到内存中。但是由于某种原因,我的属性文件不在类路径中。我右键单击属性文件并在eclipse中选择“复制限定名”以获取文件路径。但是它说该文件不存在,我觉得这很奇怪,因为我查看了我的工作示例,它位于同一个文件夹“目标”中并且工作正常。
当我单击“复制限定名称”时,我得到 /DatabaseSpringframework/target/jdbc.properties 我拿走了 /DatabaseSpringframework/ 并留下了 target/jdbc.properties 仍然是同样的错误。 这是我的 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"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd">
<context:component-scan base-package="com.learntoprogram"></context:component-
scan>
<context:property-placeholder location="target/jdbc.properties" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="username" value="${jdbc.username}"></property>
<property name="url" value="${jdbc.url}"></property>
<property name="driverClassName" value="${jdbc.driver}"></property>
</bean>
<tx:annotation-driven />
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
</bean>
</beans>
【问题讨论】: