[Spring] Spring/MyBatis/Oracle 연동&설정
2019. 4. 5. 11:06
반응형
[Spring] Spring/MyBatis/Oracle 연동 / 설정
앞글 https://rios.tistory.com/280 에서 Mybatis 설명 및 Spring / Mysql 연동 방법을
설명했으니 이번엔 oracle 버전으로 알아보도록하자.
사실 앞글에선 이론 및 mybatis 등을 설명하느라 글이 좀길어졌는데
간단하게 표현하면 설정파일 3개를 수정 ( root-context.xml , pom.xml , web.xml )
▼root-context.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 | <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> <property name="url" value="jdbc:oracle:thin:@localhost:1521:xe" /> <property name="username" value="test"/> <property name="password" value="1234"/> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="mapperLocations" value="classpath:/sqlMappers/*.xml" /> </bean> <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg index="0" ref="sqlSessionFactory" /> </bean> | cs |
▼pom.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 74 75 76 77 78 79 80 81 | <repositories> <repository> <id>mesir-repo</id> <url>http://mesir.googlecode.com/svn/trunk/mavenrepo</url> </repository> </repositories> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${org.springframework-version}</version> <exclusions> <!-- Exclude Commons Logging in favor of SLF4j --> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${org.springframework-version}</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.2.8</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.2</version> </dependency> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc14</artifactId> <version>10.2.0.4.0</version> </dependency> |
▼web.xml 설정
1 2 3 4 5 6 7 8 9 | <servlet-mapping> <servlet-name>appServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> | cs |
p.s 앞에 글을 참조하면 이후 연동 및 테스트 방법으로 사용할수있습니다.
반응형
'Program > Java' 카테고리의 다른 글
[Java] 세션(Session) 의 정의와 활용 예 (0) | 2019.07.17 |
---|---|
[Java] SSO & Crowd 설정 시 httpclient 관련 에러 해결 (0) | 2019.07.16 |
[Spring] Spring/MyBatis/MySQL 연동&설정 (0) | 2019.04.04 |
[Java] Collection - Iterator 란? (0) | 2019.03.22 |
[Java] String을 Json 객체로 변경하는법 (0) | 2019.02.26 |