스프링

 applicationContext.xml 

<?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"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://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">

	<context:annotation-config />

	<!-- mySQL DB연결위한 작업 -->
	<bean id="dataSource"
		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="net.sf.log4jdbc.sql.jdbcapi.DriverSpy">
		</property>
		<property name="url" value="jdbc:log4jdbc:mysql://127.0.0.1:3306/team4"></property>
		<property name="username" value="wjheo"></property>
		<property name="password" value="1111"></property>
	</bean>


	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="configLocation" value="classpath:/mybatis-config.xml"/>
		<property name="mapperLocations" value="classpath:mappers/**/*Mapper.xml"/>
	</bean>

	
	<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate" destroy-method="clearCache">
		<constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"/>
	</bean>




</beans>




 

 

 

 mybatis-config.xml 

 

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
	<typeAliases>
		<package name="com.java.dto"/>
	</typeAliases>



</configuration>

 

 

 class User

 

@Alias("User")
public class User {
	
	@NotNull @Size(min=4, max=12)
	private String userId; 
	
	@NotNull @Size(min=4, max=12)
	private String password;
	
	@NotNull
	private	String name;
	
	@NotEmpty @Email
	private String email;
    



...


}

 

 

 

 

 

 

 

about author

PHRASE

Level 60  머나먼나라

우리는 서로의 건강을 위해 축배하고 자신들의 건강을 해친다. - J.K. 제롬

댓글 ( 4)

댓글 남기기

작성