2015-02-05 92 views
1

出于某种奇怪的原因,此数据源bean在我的dao-beans中找到3个,但没有在其他名称中找到(例如Spring-name1)。有什么不同?未找到引用的bean'名称'

引用豆 '数据源' 未找到

这是代码:

不工作豆(春季名1):

<?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" 
     xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

    <bean id="cheopsDAO" class="se.kth.domain.dao.impl.JdbcCheopsDAO"> 
     <property name="dataSource" ref="dataSource" /> 
    </bean> 

</beans> 

工作豆(春季名2 ):

<?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" 
     xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

    <bean id="thresholdDAO" class="se.kth.domain.dao.impl.JdbcThresholdDAO"> 
     <property name="dataSource" ref="dataSource" /> 
    </bean> 

</beans> 

自旋微观-Module.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-3.0.xsd"> 

    <import resource="database/Spring-Datasource.xml" /> 
    <import resource="dao-beans/**" /> 
</beans> 

弹簧Datasource.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<beans 
    xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"> 
    <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" 
     id="dataSource"> 
     <property value="com.mysql.jdbc.Driver" name="driverClassName" /> 
     <property value="jdbc:mysql://localhost:3306/test" name="url" /> 
     <property value="root" name="username" /> 
     <property value="test" name="password" /> 
    </bean> 
</beans> 

我已经在各自的包所需的DAO文件corretly,为什么是第二个工作,但不是第一个?没有区别..

非常感谢!

+0

有什么改变,你导入死的文件直接没有whildcard? – 2015-02-05 13:04:04

+0

咦?对不起你的意思是什么?什么是通配符和什么导入?我最近没有创建它们,他们曾经工作,现在一些他们停止这样做.. – benskiiii 2015-02-05 13:06:55

+0

你把文件移动到不同的位置? (我猜猜spring-name1和spring-name2是在同一个地方,并以相同的方式导入) – Thenanox 2015-02-05 13:07:42

回答

2

我通过为我的项目添加配置集(Bean支持)来解决这个问题。不知道这是否是准确的正确的解决方案,但它删除这些错误至少:

右键单击项目 - >属性 - >春季 - >豆支持 - >配置设置 (前做一个扫描在之前的页面中),然后我将它们全部添加到一个随机配置集合中。 =)

+0

这适用于我,但我想知道它的作用。谢谢 – QGA 2015-04-02 08:28:45

相关问题