前言:
如今咱们对“ibatismysql”大体比较珍视,兄弟们都需要剖析一些“ibatismysql”的相关文章。那么小编同时在网摘上收集了一些关于“ibatismysql””的相关知识,希望姐妹们能喜欢,大家一起来学习一下吧!最近整理多年前的项目资料,其中一个项目使用springmvc+ibatis+mysql+easyui+nginx+redis完成的,包括了tomcat集群负载均衡,mysql读写分离。决定花点时间整理一下,放在公司配置库里便于新来的同事学习借鉴。
今天先整理配置文件。
1、将各相关jar拷贝到lib目录下
spring-aop.jar
spring-beans.jar
spring-context.jar
spring-core.jar
spring-jdbc.jar
spring-web.jar
spring-webmvc.jar
spring.jar
以及
ibatis.jar
等拷贝到lib下。
2、web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/config/application.xml
classpath:/config/spring_logs.xml,
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/config/springmvc-servlet.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
3、springmvc-servlet.xml
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
id="internalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="/view/" />
<!-- 后缀 -->
<property name="suffix" value=".jsp" />
</bean>
4、applicationContext.xml
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
lazy-init="default" autowire="default" dependency-check="default">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/data</value>
</property>
<property name="username">
<value>{username}</value>
</property>
<property name="password">
<value>{password}</value>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
lazy-init="default" autowire="default" dependency-check="default">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>classpath:/config/sqlMap.xml</value>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
5、sqlMap.xml
<sqlMapConfig>
<settings cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="true"/>
<sqlMap resource="config/logs/logs.xml" />
......................................
</sqlMapConfig>
今天就整理到这里,后面接着弄。
标签: #ibatismysql