这是有效的:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
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
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<beans:bean id="test2" name="name" class="org.chicago.home.Test2"> </beans:bean>
<beans:bean id="test1" class="org.chicago.home.Test1">
<beans:constructor-arg ref="test2"/>
</beans:bean>
</beans:beans>这不是。但是,我发现这种类型的配置更好。我应该对命名空间做些什么才能使下面的配置生效?
另外,我可以在constructor arg中传递idref吗?这似乎对我不起作用。构造器-arg中的idref bean="“和idref local="”都不工作。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
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
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
< I am pressing Ctrl + Space here, but it says beans doesn't have any child tags.
</beans>发布于 2012-03-28 11:11:51
您可以使用类似以下内容:
<beans xmlns="http://www.springframework.org/schema/beans"示例here
对于注入构造器,您可以使用:
<constructor-arg><ref bean="anotherExampleBean"/></constructor-arg>Spring documentation for inject constructor
发布于 2012-03-28 11:15:10
看起来你在第二个版本中可能有一个打字错误。我认为:
<beans:xmlns="http://www.springframework.org/schema/security"应该是这样:
<beans xmlns="http://www.springframework.org/schema/security"除非你只是抄袭错了。如果这不能修复它,你能发布错误消息吗?
https://stackoverflow.com/questions/9900260
复制相似问题