Let's live hard

프로젝트 구조



dev.properties 작성


ipNum=127.0.0.1
portNum=8181
userId=test
cs


run.properties 작성


ipNum=192.16.2.1
portNum=90
userId=sykim
cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?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"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd" profile="run">
 
    <context:property-placeholder
    location="classpath:run.properties" />
    
    <bean id="envInfo" class="com.ch.ex.AdminConnection">
        <property name="ipNum" value="${ipNum}"/>
        <property name="portNum" value="${portNum}"/>
        <property name="userId" value="${userId}"/>
    </bean>
    
</beans>
 
cs

properties 변수 및 getters setters 작성


package com.ch.ex;
 
public class AdminConnection {
    private String ipNum;
    private String portNum;
    private String userId;
 
    public String getIpNum() {
        return ipNum;
    }
    public void setIpNum(String ipNum) {
        this.ipNum = ipNum;
    }
    public String getPortNum() {
        return portNum;
    }
    public void setPortNum(String portNum) {
        this.portNum = portNum;
    }
    public String getUserId() {
        return userId;
    }
    public void setUserId(String userId) {
        this.userId = userId;
    }
}
 
cs


'Spring' 카테고리의 다른 글

Spring MVC기초  (0) 2017.07.31
자바 Spring 개요  (0) 2017.07.31
댓글 로드 중…

블로그 정보

it를 공부하고 있습니다.

최근에 게시된 글