제공할 서비스와 관련된 항목들을 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


+ Recent posts