Java 无法打开类路径资源[target/jdbc.properties],因为它不存在

Java 无法打开类路径资源[target/jdbc.properties],因为它不存在,java,spring,Java,Spring,我正在制作一个简单的spring应用程序。我已经在我的另一台计算机上编写了这个程序,并决定从头再做一次,以便真正将它提交到内存中。但是,由于某些原因,我的属性文件不在类路径中。我右键单击属性文件,并在eclipse中选择“复制限定名”以获取文件路径。但是它说这个文件不存在,我觉得这很奇怪,因为我看了我的工作示例,它在同一个文件夹“target”中,工作正常 当我点击“复制限定名”时,我得到了/DatabaseSpringframework/target/jdbc.properties,我拿走了/

我正在制作一个简单的spring应用程序。我已经在我的另一台计算机上编写了这个程序,并决定从头再做一次,以便真正将它提交到内存中。但是,由于某些原因,我的属性文件不在类路径中。我右键单击属性文件,并在eclipse中选择“复制限定名”以获取文件路径。但是它说这个文件不存在,我觉得这很奇怪,因为我看了我的工作示例,它在同一个文件夹“target”中,工作正常

当我点击“复制限定名”时,我得到了/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>

location=“target/jdbc.properties”
更改为
location=“classpath:jdbc.properties”
。 在类路径中查找属性文件的