250x250
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- maven
- IntelliJ
- 오픈소스
- error
- Python
- JavaScript
- 문서
- MySQL
- PostgreSQL
- Docker
- MSSQL
- AJAX
- git
- Source
- oracle
- SpringBoot
- Open Source
- ubuntu
- Tomcat
- 설정
- Spring Boot
- spring
- myBatis
- STS
- jpa
- Exception
- Thymeleaf
- Core Java
- JDBC
- Eclipse
Archives
- Today
- Total
헤르메스 LIFE
[Spring] DB Connection 본문
728x90
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/spring/applicationContext-*.xml</param-value>
</context-param>
<!-- Processes application requests -->
<servlet>
<servlet-name>rest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/config/servlet-*.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
applicationContext-resource.xml
<context:property-placeholder location="classpath:config/applicationConfig.xml"/>
applicationConfig.xml
<!-- ======================================== -->
<!-- MYSQL JDBC Configuration -->
<!-- ======================================== -->
<!-- mysql
<entry key="mysql.jdbc.driverClassName">com.mysql.jdbc.Driver</entry>
-->
<!-- log4sql - mysql driver -->
<entry key="mysql.jdbc.driverClassName">core.log.jdbc.driver.MysqlDriver</entry>
<entry key="mysql.jdbc.url">jdbc:mysql://localhost:3309/springdb</entry>
<entry key="mysql.jdbc.username">scott</entry>
<entry key="mysql.jdbc.password">tiger</entry>
applicationContext-datasource.xml
<!-- MYSQL DB POOL datasources -->
<bean id="defaultDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${mysql.jdbc.driverClassName}" />
<property name="url" value="${mysql.jdbc.url}" />
<property name="username" value="${mysql.jdbc.username}" />
<property name="password" value="${mysql.jdbc.password}" />
<property name="initialSize" value="10"/>
<property name="maxActive" value="30"/>
<property name="maxIdle" value="15" />
<property name="minIdle" value="15" />
<property name="testOnBorrow" value="false" />
<property name="validationQuery" value="select 1" />
<property name="timeBetweenEvictionRunsMillis" value="10000" />
<property name="testWhileIdle" value="true" />
<property name="numTestsPerEvictionRun" value="3" />
<property name="minEvictableIdleTimeMillis" value="-1" />
</bean>
<!-- define the SqlSessionFactory -->
<bean id="defaultSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="defaultDataSource" />
<property name="typeAliasesPackage" value="com.framework" />
<property name="configLocation" value="classpath:config/mybatisConfig.xml"/>
<property name="mapperLocations" value="classpath*:com/ framework /**/sql/*.xml" />
</bean>
<bean id="defaultSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg ref="defaultSqlSessionFactory"/>
</bean>
<!-- scan for mappers and let them be autowired
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com. framework.sample.persistence" />
</bean>
-->
<!-- transaction manager, use JtaTransactionManager for global tx -->
<bean id="defaultTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="defaultDataSource" />
</bean>
<tx:annotation-driven transaction-manager="defaultTransactionManager"/>
mybatisConfig.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>
<settings>
<setting name="cacheEnabled" value="true" /><!-- default = true -->
<setting name="useGeneratedKeys" value="true" /><!-- default = false -->
<setting name="defaultExecutorType" value="REUSE" /><!-- SIMPLE/REUSE/BATCH default = SIMPLE -->
<setting name="lazyLoadingEnabled" value="false" /><!-- default = true -->
<setting name="aggressiveLazyLoading" value="true" /><!-- default = true -->
<setting name="defaultStatementTimeout" value="25000" /><!-- Not Set(null) -->
<setting name="useColumnLabel" value="true" /><!-- default = true -->
<setting name="autoMappingBehavior" value="PARTIAL" /><!-- NONE/PARTIAL/FULL default = PARTIAL -->
<setting name="multipleResultSetsEnabled" value="true" /><!-- default = true -->
<setting name="safeRowBoundsEnabled" value="true" /><!-- default = true -->
<setting name="mapUnderscoreToCamelCase" value="false" /><!-- default = false -->
</settings>
</configuration>
https://hermeslog.tistory.com/207
728x90
'Spring Framework' 카테고리의 다른 글
[Spring] Spring + mySql 설정 (0) | 2012.02.23 |
---|---|
[DBCP]DBCP (Database connection pooling services) (0) | 2012.02.15 |
[Spring] Annotation Reference for Spring Projects (0) | 2012.01.19 |
Spring 참고 사이트 목록 (0) | 2012.01.09 |
성능을 위한 초간단 HTTP 304 Not Modified 구현 방법 (0) | 2011.10.05 |