본문 바로가기

IT I 프로그래밍/자바 I 스프링 설정

[12] 스프링(Spring Tools 4) root-context.xml에서 <beans>의 속성 변경

[12] 스프링(Spring Tools 4) root-context.xml에서 <beans>의 속성 변경

 

1. 스프링(Spring Tools 4) root-context.xml에서 <beans>의 속성 변경

> WEB-INF > Spring > root-context.xml


<?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:jdbc="http://www.springframework.org/schema/jdbc"
  xsi:schemaLocation="http://www.springframework.org/schema/jdbc   
  http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
  http://www.springframework.org/schema/beans   
  http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/util     
  http://www.springframework.org/schema/util/spring-util-3.1.xsd">
   
   <!-- Root Context: defines shared resources visible to all other web components -->
   
   <bean name="dsdbcp" class="org.apache.commons.dbcp2.BasicDataSource">
      <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
      <property name="url" value="jdbc:mysql://localhost:3306/jspdb?characterEncoding=utf8"/>
      <property name="username" value="root"/>
      <property name="password" value="1234"/>
      <property name="initialSize" value="5"/>
      <property name="maxIdle" value="5"/>
   </bean>     
    
    <bean id="jdbcTmp" class="org.springframework.jdbc.core.JdbcTemplate">
       <constructor-arg ref="dsdbcp"/>
    </bean>       
</beans>