2012-03-28 6 views
0

Cela fonctionne:Le printemps évitant les haricots: les haricots et les haricots d'écriture à la place?

<?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> 

Ce n'est pas. Mais, je trouve mieux ce type de configuration. Que dois-je faire à l'espace de noms pour faire fonctionner cette configuration ci-dessous?

De même, puis-je passer idref dans le constructeur-arg? Cela ne semble pas fonctionner pour moi. Ni idref bean = "" ni idref local = "" dans le constructeur-arg travaille.

<?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> 

Répondre

0

Vous pouvez utiliser quelque chose comme:

<beans xmlns="http://www.springframework.org/schema/beans" 

Exemple here

Pour inject constuctor, vous pouvez utiliser:

<constructor-arg><ref bean="anotherExampleBean"/></constructor-arg> 

Spring documentation for inject constructor

0

Il semble que vous pourriez avoir une faute de frappe dans la deuxième version. Je pense que ceci:

<beans:xmlns="http://www.springframework.org/schema/security" 

devrait être le suivant:

<beans xmlns="http://www.springframework.org/schema/security" 

À moins que vous venez de copier mal. Si cela ne le résout pas, pouvez-vous poster le message d'erreur?

Questions connexes