Dev/Java

[Spring] properties, @Value

냐옴 2019. 6. 21. 14:04

my-prop.properties

prop.key1 = 123
prop.key2 = true

 

servlet.xml

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

    <util:properties id="myProp" location="classpath:properties/my-pop.properties"/>

</beans>

 

controller

@Value("#{myProp['prop.key1']}")
private String myValue1;

@Value("#{'true'.equals(myProp['prop.key2'])}")
private boolean myValue2;
저작자표시 비영리 동일조건 (새창열림)