SSM-based MAVEN project (Redis and MySQL) profile consolidation

Source: Internet
Author: User

Src/main/resources

1. db folder

1.1 Db.properties

Jdbc.driverclass=com.mysql.jdbc.driverjdbc.url=jdbc:mysql://192.168.175.102:3306/zy_video2?userssl= Falsejdbc.user=zy103[email protected]redis.host=192.168.175.102redis.port=6379redis.pass=123456redis.maxtotal= 30redis.maxidle=5

1.2 Db.sql

2. MyBatis Folder

2.1 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><!--turn the underline to hump  --><settings><setting name=" Mapunderscoretocamelcase "value=" true "/></settings></configuration>

2.2 DAO corresponds to the generated mapper file

3. Spring Folder

3.1 Spring-dao.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" 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.xsd "><!--Scan and identify spring-related annotations: @service @Componnent @Repository ...--><context: Component-scan base-package= "com.zhiyou100"/> <!--loading Db.properties--><context:property-placeholder location= "Classpath:db/db.properties"/><!--c3p0--><bean id= "DataSource" class= " Com.mchange.v2.c3p0.ComboPooledDataSource "><property name=" Driverclass "value=" ${jdbc.driverclass} "/> <property name= "Jdbcurl" value= "${jdbc.url}"/><property name= "user" value= "${jdbc.user}"/><property Name= "Password" value= "${jDbc.password} "/></bean> <!--configuration sqlsessionfactory related configuration--><bean id=" Sqlsessionfactory "class=" Org.mybatis.spring.SqlSessionFactoryBean "><!--injection data source--><property name=" DataSource "ref=" DataSource " ></property><!--Set the path to the MyBatis configuration file--><property name= "configlocation" value= "classpath:mybatis/ Mybatis-config.xml "></property><!--turn on alias, default to lowercase--><property name=" typealiasespackage "value= "Com.zhiyou100.model" ></property><!--set Mapper file path--><property name= "Mapperlocations" value= " Classpath:mybatis/*mapper.xml "></property></bean><!--inject the implementation class of the DAO interface into the spring container, using a name or type to get the object-- ><bean class= "Org.mybatis.spring.mapper.MapperScannerConfigurer" ><!--the interface under the DAO package Implementation class injected into the spring container--><property name= "Basepackage" value= "Com.zhiyou100.dao" ></property></bean ></beans>

3.2  spring-redis.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:tx= "Http://www.springframework.org/schema/tx" 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.xsd Http://www.springframework.org/schema/tx http:/ /www.springframework.org/schema/tx/spring-tx.xsd "> <!--read the contents of the configuration file--<context:property-placeholder location= "Classpath:db/db.properties"/> <!--configuration jpc jedispoolconfig for reasonable estimation of configuration--<bean id= "JPC" class= " Redis.clients.jedis.JedisPoolConfig "> <property name=" maxtotal "value=" ${redis.maxtotal} "></property > <property name= "maxidle" value= "${redis.maxidle}" ></property> </bean> <!--withJCF, link factory, used to generate Redis link objects jedisconnectionfactory--> <bean id= "JCF" class= " Org.springframework.data.redis.connection.jedis.JedisConnectionFactory "> <property name=" hostName "value=" $ {redis.host} "></property> <property name=" Port "value=" ${redis.port} "></property> < Property name= "Password" value= "${redis.pass}" ></property> <property name= "Poolconfig" ref= "JPC" > </property> </bean> <!--redistemplate objects for various operations on Redis--<bean id= "redistemplate" class= "Org.s Pringframework.data.redis.core.RedisTemplate "> <property name=" connectionfactory "ref=" JCF "></ Property> <!--set the encoding format to UTF-8--<property name= "Keyserializer" ><bean class= " Org.springframework.data.redis.serializer.StringRedisSerializer "/></property> </bean></beans >

3.3  sprinf-service.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:tx= "Http://www.springframework.org/schema/tx" 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.xsd Http://www.springframework.org/schema/tx http:/ /www.springframework.org/schema/tx/spring-tx.xsd "><!--Spring Configuration for service tier--><!--1. Packet Scan @service-- ><context:component-scan base-package= "Com.zhiyou100.service" ></context:component-scan><!--2. Provides transactional support for methods--><bean id= "TransactionManager" class= " Org.springframework.jdbc.datasource.DataSourceTransactionManager "><!--inject database connection pool, transaction is-->< in database Property Name= "DataSource" ref= "DataSource" ></property></bean><!--Use the simplest declarative transactional operation, with annotations to complete--><tx:annotation-driven transaction-manager= " TransactionManager "/></beans>

3.4  spring-web.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:mvc= "Http://www.springframework.org/schema/mvc" 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.xsd http://www.springframework.org/schema/ MVC http://www.springframework.org/schema/mvc/spring-mvc.xsd "><!--package Scan--><context:component-scan Base-package= "Com.zhiyou100.controller"/><!--opening annotations--><mvc:annotation-driven/><bean class= " Org.springframework.web.servlet.view.InternalResourceViewResolver "><!--the path prefix of the returned JSP file--><!-- Placed under the Web-inf. JSP cannot be accessed by URL, can improve the security of data-<property name= "prefix" value= "/web-inf/view/" ></property > <!--Returns the path suffix of the JSP file--<property name= "suffix" value= ". JSP" ></property></bean><!--using the default handler, Support for static access--><mvc:default-servlet-handler/></beans>

4.web.xml

<?xml version= "1.0" encoding= "UTF-8"? ><web-app xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns= "Http://xmlns.jcp.org/xml/ns/javaee" xsi:schemalocation= "Http://xmlns.jcp.org/xml/ns/javaee/http Xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd "id=" webapp_id "version=" 3.1 "><display-name>videoadmin</ Display-name><welcome-file-list><welcome-file>index.html</welcome-file><welcome-file >index.htm</welcome-file><welcome-file>index.jsp</welcome-file><welcome-file> Default.html</welcome-file><welcome-file>default.htm</welcome-file><welcome-file> default.jsp</welcome-file></welcome-file-list><!--The configuration of spring--><!-- To load and parse the spring configuration file when the server is started--><listener><listener-class> org.springframework.web.context.contextloaderlistener</listener-class></listener><!-- Specifies the file path of spring--&GT;&LT;CONTEXT-PARAM&GT;&LT;PARAM-NAME&GT;CONTEXTCONFIGLOCATION&LT;/PARAM-NAME&Gt;<param-value>classpath:spring/spring-*.xml</param-value></context-param><!--Configuration character encoding-- ><filter><filter-name>encodingFilter</filter-name><filter-class> Org.springframework.web.filter.characterencodingfilter</filter-class><init-param><param-name >encoding</param-name><param-value>UTF-8</param-value></init-param></filter> <filter-mapping><filter-name>encodingfilter</filter-name><url-pattern>/*</ Url-pattern></filter-mapping><servlet><servlet-name>dispatcherservlet</servlet-name ><servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class><init-param ><param-name>contextconfiglocation</param-name><param-value>classpath:spring/ Spring-mvc.xml</param-value></init-param></servlet><servlet-mapping><servlet-name >dispatcherservlet</servlet-name><url-pattern>/</url-pattern></servlet-mapping></web-app> 

5.  pom.xml

<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >< Modelversion>4.0.0</modelversion><groupid>com.zhiyou100</groupid><artifactid> Redistest3</artifactid><version>0.0.1-snapshot</version><packaging>war</packaging ><dependencies><!--MyBatis Jar--><dependency><groupid>org.mybatis</groupid> <artifactId>mybatis</artifactId><version>3.4.5</version></dependency><!--c3p0 --><dependency><groupid>com.mchange</groupid><artifactid>c3p0</artifactid> <version>0.9.5.2</version></dependency><!--MySQL driver--><dependency><groupid >mysql</groupid><artifactid>mysql-connector-java</artifactid><version>5.1.43</ version></dependency><!--MyBatis and spring integrated jar--><dependency><groupid>org.mybatis</groupid><artifactid >mybatis-spring</artifactId><version>1.3.1</version></dependency><!--Auto-Import dependent- ><dependency><groupid>org.springframework</groupid><artifactid>spring-webmvc</ artifactid><version>4.3.10.release</version></dependency><!--https://mvnrepository.com /artifact/org.springframework/spring-jdbc--><dependency><groupid>org.springframework</ groupid><artifactid>spring-jdbc</artifactid><version>4.3.10.release</version></ dependency><!--Spring Transaction--><dependency><groupid>org.springframework</groupid>< artifactid>spring-tx</artifactid><version>4.3.10.release</version></dependency>< !--Servlet-api--><dependency><groupid>javax.servlet</groupid><artifactid> javax.servlet-api</artifactid><version>3.1.0</version><scope>provided</scope></dependency><!- -Jackson's Jar pack--><dependency><groupid>com.fasterxml.jackson.core</groupid><artifactid >jackson-core</artifactId><version>2.9.1</version></dependency><dependency> <groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId> <version>2.9.1</version></dependency><!--Redis--><dependency><groupid> Org.springframework.data</groupid><artifactid>spring-data-redis</artifactid><version> 1.8.7.release</version></dependency><dependency><groupid>redis.clients</groupid> <artifactid>jedis</artifactid><version>2.9.0</version></dependency></ Dependencies><build><plugins><plugin><groupid>org.apache.tomcat.maven</groupid ><artifactid>tomcat7-maven-plugin</artifactid><version>2.2</version></plugin><plugin>< groupid>org.apache.maven.plugins</groupid><artifactid>maven-war-plugin</artifactid>< configuration><webresource><!--do not package the file under the test directory--><resource><directory>src/test</ directory><excludes><exclude>*</exclude></excludes></resource></ Webresource></configuration></plugin></plugins></build></project>

SSM-based MAVEN project (Redis and MySQL) profile consolidation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.