Results 1 to 2 of 2

Thread: configuring variable with xml

  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Default configuring variable with xml

    Hi all, I'm trying to configure a variable with spring, in my spring-servlet.xml i wrote:

    Code:
    	<import resource="classpath:spring-context.xml" />
    in the file spring-context.xml i wrote:

    Code:
    <?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:util="http://www.springframework.org/schema/util"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    						http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
    						http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    
    	<context:property-placeholder properties-ref="defaultProperties" />
    	
    	<util:properties id="defaultProperties">
    		<prop key="address">this is an address</prop>
    	</util:properties>
    </beans>
    finally in my class i wrote:
    Code:
            @Autowired
    	@Value(value = "${address}")
    	private String address;
    Any suggestion? thanks

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    And where is your class defined? Is see no component scanning and no bean definition so your beanisn't known by spring and as such will not be injected.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •