1. Namespace에 사용하는 부분 체크
- 여기에 뜨는 것들은 https://jungeun980906.tistory.com/354 (pom.xml)에 라이브러리를 넣은 것들임!
- 만약 필요한 부분이 뜨지 않는다면, pom.xml을 확인해보기!
- aop, context, jdbc, mybatis 추가 체크하고 저장!
- 추후에 추가 예정 : pom.xml에 추가하고 root-context.xml에서 체크
https://mvnrepository.com/artifact/org.springframework/spring-test
2. Source에 DB 설정
spring_project에서 사용할 DB와 user 미리 정해놓기!
DB : springtest
user : springuser
password : mysql
<?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:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.3.xsd
http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
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
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.cj.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/springtest"></property>
<property name="username" value="springuser"></property>
<property name="password" value="mysql"></property>
</bean>
<bean id="sqlSessionFactory"
class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="mapperLocations" value="classpath:mappers/**/*Mapper.xml"></property>
<!-- /**/의 의미는 폴더안의 어떤 폴더안의 폴더로 들어갈 경우 대비한 설정 -->
</bean>
<mybatis-spring:scan base-package="com.myweb.www.repository"/>
<!-- src/main/java안의 패키지이름.repository 넣기 -->
</beans>
여기까지 생성하면 출력화면
'Spring > Spring 공부' 카테고리의 다른 글
[spring] BCryptPasswordEncoder : 패스워드 암호화 클래스 (0) | 2023.06.05 |
---|---|
[spring] 1. DB 생성, STS 기본 생성 (0) | 2023.06.05 |
[spring] 프로젝트 설정 0-2. web.xml 설정 (0) | 2023.06.02 |
[spring] 프로젝트 설정 0-1. pom.xml 설정 (0) | 2023.06.02 |
[spring] STS 설정하기 (0) | 2023.06.02 |