제공할 서비스와 관련된 항목들을 service.xml에 세팅한다.
세팅한 서비스는 3가지다(dataSource, factorybean, template)
mariadb를 사용할 계획이기 때문에 jndi-lookup에 jdbc/mariadb를 입력한다.
브라우저에 현재까지 세팅한 내용이 반영되는지 확인을 하고 classpath에 입력한 대로 config 및 mybatis 세팅을 한다.
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 | <?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:jee="http://www.springframework.org/schema/jee" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- dataSource --> <jee:jndi-lookup id="dataSource" jndi-name="jdbc/mariadb" resource-ref="true"/> <!-- factorybean 등록 --> <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean" p:dataSource-ref="dataSource" p:configLocation="classpath:com/p_rest/mybatis/config/config.xml" /> <!-- 필요한 template 활용 --> <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg ref="sqlSessionFactoryBean"/> </bean> </beans> | cs |
'문돌이의 IT > Spring' 카테고리의 다른 글
스프링(Spring)을 활용한 개인프로젝트 (0) | 2016.12.03 |
---|---|
스프링 웹프로젝트 Spring STS 설치하기 (0) | 2016.12.02 |
Spring front.xml 세팅하기(restFul 적용) (0) | 2016.06.10 |
[Spring] Hibernate 사용하기 (0) | 2016.06.09 |
Spring Web.xml 세팅하기 (0) | 2016.06.08 |