Skip to content

Instantly share code, notes, and snippets.

@relax-more
Created February 4, 2013 06:52
Show Gist options
  • Save relax-more/4705334 to your computer and use it in GitHub Desktop.
Save relax-more/4705334 to your computer and use it in GitHub Desktop.
java SpringFramework Controller の変数にannotationを利用して値を設定する
any.property.value=value
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
">
<bean id="anyProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:resources/properties/any.properties</value>
</list>
</property>
</bean>
</beans>
public class SomeController{
@Value(value = "#{anyProperties['any.property.value']}")
private String value;
// 中略
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment