40 likes | 142 Views
Property. ㅇ < context:property-placeholder > - < context:property-placeholder location =" classpath:config.properties " />. Java. config.properties. @Value(“${prop}”) private String prop; @Value(“${ prop.id}”) private String propId ; @Value(“${ prop.pw}”)
E N D
Property ㅇ<context:property-placeholder> - <context:property-placeholder location="classpath:config.properties" /> Java config.properties @Value(“${prop}”) private String prop; @Value(“${prop.id}”) private String propId; @Value(“${prop.pw}”) private String propPw; prop=Test prop.id=seorab prop.pw=pass db.driver=oracle.jdbc.driver.OracleDriver db.url=jdbc:oracle:thin:@localhost:1521:xe db.id=scott db.pw=tiger
Property ㅇ<context:property-placeholder> - <context:property-placeholder location="classpath:config.properties" /> xml <context:property-placeholder location="classpath:edu/seowon/jdbc/config.properties" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="${db.driver}" /> <property name="url" value="${db.url}" /> <property name="username" value="${db.id}" /> <property name="password" value="${db.pw}" /> </bean>
Property ㅇ<util:properties> - <util:properties id="config" location="classpath:edu/seowon/jdbc/config.properties" /> Java config.properties @Value(“#{config[‘prop’]}”) private String prop; @Value(“#{config[‘prop.id’]}”) private String propId; @Value(“#{config[‘prop.pw’]}”) private String propPw; prop=Test prop.id=seorab prop.pw=pass db.driver=oracle.jdbc.driver.OracleDriver db.url=jdbc:oracle:thin:@localhost:1521:xe db.id=scott db.pw=tiger
Property ㅇ<util:properties> - <util:properties id="config" location="classpath:edu/seowon/jdbc/config.properties" /> xml <util:properties location="classpath:edu/seowon/jdbc/config.properties" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value=“#{config[‘db.driver’]}" /> <property name="url" value=“#{config[‘db.url’]}" /> <property name="username" value=“#{config[‘db.id’]}" /> <property name="password" value=“#{config[‘db.pw’]}" /> </bean>