Application attribute file in the controller layer

After setting a env.properties file, if the application in the service, you

@Value ( "image_url $ {}" ) // property named image_url
     Private String The IMAGE_URL;

Add property files applicationContext.xml profile

<context:property-placeholder location="classpath:*.properties"/>

If the application layer in the controller, the controller layer due Spring loading profile is not loaded, it is not directly used, the need for additional configuration properties file springmvc-servlet.xml

<context:property-placeholder location="classpath:env.properties"/>

Then controller in the same method as above

Guess you like

Origin www.cnblogs.com/psxfd4/p/11668056.html