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 | <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>11.1.0.7.0</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.5</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.3.1</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>4.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.8.9</version> </dependency> | cs |
pom.xml에 위 다섯개의 dependecies를 추가해준다.
commons-dbcp의 1.4버전도 추가해준다.
spring 폴더 아래에 Spring Bean Definition file인 rootContext.xml 을 만들어준다.
<rootContext.xml>
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | <?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd"> <!-- Connection Pool --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property> <property name="url" value="jdbc:oracle:thin:@localhost:1521:XE"></property> <property name="username" value="HR"></property> <property name="password" value="hr"></property> </bean> <!-- MyBatis 가 사용할 Database에 연결하도록 설정 --> <bean id="sqlSession" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> </bean> <!-- MyBatis의 CRUD 템플릿을 사용할 수 있도록 설정 --> <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg ref="sqlSessionFactory"/> </bean> <!-- Transactio 설정하기 --> <!-- Transactio Manager 설정 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <!-- Transaction 대상 설정 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="tx*" rollback-for="RuntimeException"/> <tx:method name="insert*" rollback-for="RuntimeException"/> <tx:method name="write*" rollback-for="RuntimeException"/> <tx:method name="add*" rollback-for="RuntimeException"/> <tx:method name="create*" rollback-for="RuntimeException"/> <tx:method name="regist*" rollback-for="RuntimeException"/> <tx:method name="set*" rollback-for="RuntimeException"/> <tx:method name="update*" rollback-for="RuntimeException"/> <tx:method name="modify*" rollback-for="RuntimeException"/> <tx:method name="edit*" rollback-for="RuntimeException"/> <tx:method name="change*" rollback-for="RuntimeException"/> <tx:method name="delete*" rollback-for="RuntimeException"/> <tx:method name="remove*" rollback-for="RuntimeException"/> <tx:method name="terminate*" rollback-for="RuntimeException"/> <tx:method name="read*" read-only="true"/> <tx:method name="select*" read-only="true"/> <tx:method name="get*" read-only="true"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut expression="execution(public * com.ktds.jgbaek..web.*.*(..))" id="controllerTx"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="controllerTx"/> </aop:config> </beans> | cs |
<서버 올리는 방법 - 환경설정편>
물리적 spring의 lib의 jar 파일 삭제
Run As -> Maven Clean -> Maven Build
-> install:install-file -Dfile=D:\my-utilities-1.0.jar -DgroupId=my-utilities -DartifactId=my-utilities -Dversion=1.0 -Dpackaging=jar
->
pom.xml 에 추가
<dependency>
<groupId>my-utilities</groupId>
<artifactId>my-utilities</artifactId>
<version>1.0</version>
</dependency>
-> Run As -> Maven Build.. -> clean install
'Back-end > Spring' 카테고리의 다른 글
[Spring] Insert, Select, 실습 (0) | 2016.04.20 |
---|---|
[Spring] DB를 사용하는 방법 - myBatis 개념 (0) | 2016.04.20 |
[Spring] ORM : MyBatis 연동 (0) | 2016.04.19 |
[Spring] Controller Biz 사용하기 (0) | 2016.04.18 |
[Spring] Controller 리턴타입 (0) | 2016.04.15 |