我正在研究spring spring-3.2.2。我在eclipse中创建了两个java项目。
- 弹簧测试
- 测试类路径
SpringTest 项目具有以下 beans.xml,其中定义了一个 bean。
<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">
<bean id="helloWorld" class="com.spring.HelloWorld" init-method="testUpdate" scope="prototype">
<property name="message" value="Hello World!"/>
</bean>
</beans>
我已经创建了项目 SpringTest 的 jar springtest.jar,并将其添加到项目 Testclasspath 的类路径中。Testclasspath 项目的 Bean 配置文件是 Talentacquisition.xml,它正在导入 Springtest 项目的 beans.xml 文件。请找到以下人才获取.xml 内容
<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="Beans.xml"/>
<bean id="juggler" class="com.springaction.springidol.Juggler" />
</beans>
我对 Talentacquisition.xml 中导入标记的行为感到困惑它如何能够找到存在于类路径中的 jar (springtest.jar) 中的 Beans.xml 并能够加载 bean?为什么 spring 没有给出任何错误?难道我必须将 Talentacqusition.xml 中的导入标签修改为以下
<import resource="classpath:Beans.xml"/>
如果 import 能够找到文件 Beans.xml ,那么我们应该什么时候使用 classpath:和classpath* :?