일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- resource
- ssh
- context
- Windows
- Source
- find
- port
- IntelliJ
- web.xml
- tomcat
- lsof
- profile
- Mac
- Eclipse
- 네트워크
- netsh
- Windows 10
- bash
- 줄바꿈 문자
- grep
- 단축키
- maVen
- plugin
- JavaScript
- GIT
- vscode
- import
- Quartz
- VirtualBox
- xargs
- Today
- Total
develog
[Spring] Spring 2.5, Properties 본문
TestMainProperties.java
import java.util.Properties; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; public class TestMainProperties {
public static void main(String[] args) throws Exception { System.out.println("START"); System.out.println("------------------------------------------------"); TestMainProperties main = new TestMainProperties(); main.init();
System.out.println("------------------------------------------------"); System.out.println("END"); }
private void init() throws Exception { ApplicationContext context = new FileSystemXmlApplicationContext("classpath:spring-config.xml");
Properties properties = (Properties) context.getBean("properties"); System.out.println("properties : " + properties); } } |
spring-config.xml
<beans default-autowire="no" default-lazy-init="false" default-dependency-check="none" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd "> <bean id="properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="locations"> <list> <value>classpath:sample.properties</value> <value>classpath:sample2.properties</value> </list> </property> </bean>
<context:annotation-config />
</beans> |
sample.properties
name1=val1 name2=val2 |
sample2.properties
name21=val21 # name22=val22 |
'Dev > Spring' 카테고리의 다른 글
[Spring] static method injection (0) | 2014.11.11 |
---|---|
[Spring] Spring 2.5, Properties #2 (0) | 2014.11.11 |
[Spring] beans xml schema (0) | 2014.10.15 |
Spring 에서 HttpServletRequest 접근 (0) | 2013.12.11 |
LogAspect (0) | 2013.12.11 |