고마구의 개발 블로그
240717 spring jdbc 4가지 넣을거 본문
pom.xml 스프링 위에 붙여넣기
<!-- https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc8 -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>21.5.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.5.RELEASE</version>
</dependency>
서블릿-콘텍스트xml
<context:component-scan base-package="com.human.service" />
추가
루트 콘텍스트에 추가
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
<bean
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
name="dataSource">
<property value="oracle.jdbc.driver.OracleDriver" name="driverClassName"/>
<property value="jdbc:oracle:thin:@localhost:1521:xe" name="url"/>
<property value="c##human" name="username"/>
<property value="human" name="password"/>
</bean>
<bean id="sqlSessionFactory"
class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation"
value="classpath:/mybatis-config.xml"></property>
<property name="mapperLocations"
value="classpath:mappers/**/*Mapper.xml"></property>
</bean>
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate"
destroy-method="clearCache">
<constructor-arg name="sqlSessionFactory"
ref="sqlSessionFactory"></constructor-arg>
</bean>
<context:component-scan base-package="com.human.service" />
</beans>
'KDT풀스택과정 공부' 카테고리의 다른 글
240719 13주차 금요일 - Spring 05 (0) | 2024.07.19 |
---|---|
240718 13주차 목요일 - Spring 04 (0) | 2024.07.18 |
240716 13주차 화요일 - Spring 02 (0) | 2024.07.16 |
240715 13주차 월요일 - 스프링 01 (0) | 2024.07.15 |
240714 12주차 일요일 미니 프로젝트 쇼핑몰 제작 10 (0) | 2024.07.14 |