Yesterday with a small fan in the chat, he told me cry recently very difficult, I think he is said to look for a job very difficult, and then when I’m going to give him a variety of, he didn’t tell me, is my project, my project and my internship conflict, don’t have enough time to prepare, Chad and he said their school is not strict, but there is such a broken?

Ha, ha, ha, ha, remember my graduation project, a cup of coffee, a computer, a graduation project to write all day, sat in the dormitory corridor to revise the paper until 5 am, after listening to his needs, I turned over a lot of things, found a pure SSM framework that I organized when I graduated

So maybe today’s content for just graduated or just contact with programming programmers, a set of pure SSM framework to share with you, each part will have detailed annotation explanation, I hope to help you learn

Follow me public account: Java Architect Alliance, we grow and progress together, ok, business

Start the configuration

The directory structure can be modified by yourself, but be sure to change the paths in all configuration files at the same time

web.xml

<? The XML version = "1.0" encoding = "utf-8"? > <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" Xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version = "3.0" > <display-name>xss</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <! </welcome-file-list> <! <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <! The ContextLoaderListener is used to automatically assemble ApplicationContext configuration information when the Web container is started. Because it implements the ServletContextListener interface, when the web.xml listener is configured and the container is started, Will default to the method to realize it -- - > < listener - class > org. Springframework. Web. Context. ContextLoaderListener < / listener - class > < / listener > <! <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> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> <! --> <init-param> <param-name>development</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <! -- Front-end controller --> <servlet> < servletname > Springmvc </ servletname > <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <! <param-name>contextConfigLocation</param-name> contextConfigLocation</param-name> <param-value>classpath:springmvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <! Springmvc </servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name >default </servlet-name > <url-pattern >*.js</url-pattern> </servlet-mapping > <servlet-mapping > <servlet-name >default </servlet-name > <url-pattern >*.css</url-pattern> </servlet-mapping > </web-app>Copy the code

applicationContext.xml

<? The XML version = "1.0" encoding = "utf-8"? > <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> <! <context:component-scan base-package="com.*. Service "></context:component-scan> <! - loading other configuration files - > < import resource = "classpath: applicationContext - mybatis. XML" / > <! - import the configuration properties file -- > < bean class = "org. Springframework. Beans. Factory. Config. Accomplished" > <! --> <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /> <! <property name="ignoreResourceNotFound" value="true" /> <property name="locations"> <list> <value>classpath*:db.properties</value> </list> </property> </bean> <! - = = = = = = = = = = = = = = = = = = druid connection pool configuration = = = = = = = = = = = = = = = = = = -- -- > < bean id = "dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <! ${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <! ${ds.initialSize}" /> <property name="minIdle" value="${ds.minIdle}" /> <property name="maxActive" value="${ds.maxActive}" /> <! <property name="maxWait" value="${ds.maxWait}" /> <! -- How often does the configuration check for idle connections that need to be closed, Unit is milliseconds - > < property name = "timeBetweenEvictionRunsMillis" value = "${ds. TimeBetweenEvictionRunsMillis}" / > <! - configure a connection in the pool minimum survival time, the unit is milliseconds - > < property name = "minEvictableIdleTimeMillis" value = "${ds. MinEvictableIdleTimeMillis}" / > <! -- Open PSCache, And specify the size of the PSCache on each connection --> <property name="poolPreparedStatements" value="true" /> <property name="maxPoolPreparedStatementPerConnectionSize" value="20" /> <! -- JDBC Proxy Driver --> <property name="proxyFilters"> <list> <ref bean="stat-filter" /> </list> </property> </bean> <! -- SQL merge configuration, slow SQL record like secret key configuration --> <! -- <property name="connectionProperties" value="druid.stat.mergeSql=true,druid.stat.slowSqlMillis=1000; config.decrypt=true; config.decrypt.key=${publicKey}" /> --> <bean id="stat-filter" class="com.alibaba.druid.filter.stat.StatFilter"> <property name="slowSqlMillis" value="1000" /> <property name="logSlowSql" value="true" /> <property name="mergeSql" value="true" /> </bean> <! - the transaction statement - > < bean id = "txManager" class = ". Org. Springframework. JDBC datasource. DataSourceTransactionManager "> < property name="dataSource" ref="dataSource" /> </bean> <tx:annotation-driven proxy-target-class="false" transaction-manager="txManager" /> </beans>Copy the code

applicationContext-mybatis.xml

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"  xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd "> <! - mapper configuration - > < bean id = "sqlSessionFactory" class = "org. Mybatis. Spring. SqlSessionFactoryBean" > <! < dataSource ="dataSource"></property> <! - loading mybatis global configuration file - > < property name = "configLocation" value = "classpath: mybatis/mybatis - config. XML" > < / property > <property name="typeAliasesPackage" value="com.xss.pojo"></property><! - database entity class - > < property name = "mapperLocations" > < list > < value > classpath: mybatis mapper / *. XML value > < / < / list > < / property > <! - page plug-in - > < property name = "plugins" > < array > < bean class = "com. Making. Pagehelper. PageInterceptor" > < property name="properties"> <value> helperDialect=mysql offsetAsPageNum=true <! -- Prevent abnormal conditions that are smaller than the first page and larger than the last page. --> reasonable=true </value> </property> </bean> <bean class="com.github.abel533.mapperhelper.MapperInterceptor"> <property name="properties"> <value> <! - a primary key on the back to write method, the default value of MYSQL - > IDENTITY = MYSQL mappers = com. Making. Abel533. Mapper. Mapper value > < / < / property > < / bean > < / array > </property> </bean> <! Configure mapper beans and import mapper beans in batches using packet scanning. In this way, all the configuration of Mybatis is handed over to Spring to manage the class name. Pay attention to the first letters lowercase - > < bean class = "org. Mybatis. Spring. Mapper. MapperScannerConfigurer" > <! -- Specifies the full path for scanning packets. <property name="basePackage" value="com.*. Mapper "></property> </bean> </beans>Copy the code

mybatis-config.xml

<? The 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"/> <! <setting name="lazyLoadingEnabled" value="true"/> <! - for unknown SQL queries, allowed to return to a different result sets in order to achieve the effect of general - > < setting name = "multipleResultSetsEnabled" value = "true" / > <! <setting name="useColumnLabel" value="true"/> <! Setting name="useGeneratedKeys" value="false"/> <! FULL,PARTIAL --> <setting name="autoMappingBehavior" value="PARTIAL"/> <! -- Allows using RowBounds on nested statements --> <setting name="safeRowBoundsEnabled" value="false"/> <! -- Enables automatic mapping from classic database column names A_COLUMN to camel case classic Java property names aColumn. --> <setting name="mapUnderscoreToCamelCase" value="true"/> <! -- MyBatis uses local cache to prevent circular references and speed up repeated nested queries. By default (SESSION) all queries executed during a session are cached. If localCacheScope=STATEMENT local session will be used just for statement execution, no data will be shared between two different calls to the same SqlSession. --> <setting name="localCacheScope" value="SESSION"/> <! -- Specifies the JDBC type for null values when no specific JDBC type was provided for the parameter. Some drivers require specifying the column JDBC type but others work with generic values like NULL, VARCHAR or OTHER. --> <setting name="jdbcTypeForNull" value="OTHER"/> <! -- Specifies which Object's methods trigger a lazy load --> <setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString"/> <! -- Set the loading mode of the associated object, where the field is loaded on demand (the loading field is specified by SQL), not all fields of the associated table are loaded. Introduction to slogs --> <setting name=" Slogs "value="false"/> <setting name="logImpl" value="STDOUT_LOGGING"/> </settings> <typeAliases> <! -- Note: model table object configuration, please follow the order of model package input, and do a good comment. <package name="cn.xss.pojo"/> </typeAliases> <plugins> <plugin interceptor="com.github.abel533.mapperhelper.MapperInterceptor"> <! <property name="IDENTITY" value="MYSQL" /> <! -- Universal Mapper interface, Several common interface using commas - > < property name = "mappers" value = "com. Making. Abel533. Mapper. Mapper" / > < / plugin > < / plugins > </configuration>Copy the code

db.properties

JDBC. Driver = com. Mysql. JDBC. Driver # \ u672C \ u5730 \ u6570 \ u636E \ u5E93 JDBC url = JDBC: mysql: / / 127.0.0.1:3306 / XSS? allowMultiQueries=true&useUnicode=true&characterEncoding=utf-8 jdbc.username=root jdbc.password=root ##DataSource Global  Setting #\u914D\u7F6E\u521D\u59CB\u5316\u5927\u5C0F\u3001\u6700\u5C0F\u3001\u6700\u5927 ds.initialSize=10 ds.minIdle=5 ds.maxActive=12 #\u914D\u7F6E\u83B7\u53D6\u8FDE\u63A5\u7B49\u5F85\u8D85\u65F6\u7684\u65F6\u95F4 ds.maxWait=60000 #\u914D\u7F6E\u95F4\u9694\u591A\u4E45\u624D\u8FDB\u884C\u4E00\u6B21\u68C0\u6D4B\uFF0C\u68C0\u6D4B\u9700\u8981\u5173\u95E D\u7684\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2 ds.timeBetweenEvictionRunsMillis=60000 # \u914D\u7F6E\u4E00\u4E2A\u8FDE\u63A5\u5728\u6C60\u4E2D\u6700\u5C0F\u751F\u5B58\u7684\u65F6\u95F4\uFF0C\u5355\u4F4D\u662F \u6BEB\u79D2 ds.minEvictableIdleTimeMillis=300000Copy the code

springmvc.xml

<? The XML version = "1.0" encoding = "utf-8"? > <beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd 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"> <! <context:component-scan base-package="com.*. Controller "></context:component-scan> <! -- Enables the Spring MVC @Controller programming model --> <mvc:annotation-driven /> <! No mapping found for HTTP request with URI error --> < MVC :default-servlet-handler /> <! -- Support for returning JSON (avoid IE in ajax request, Return json in download) - > < bean class = "org. Springframework. Web. Servlet. MVC. The annotation. AnnotationMethodHandlerAdapter" > < property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter" /> </list> </property> </bean> <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/plain; charset=UTF-8</value> <value>application/json; charset=UTF-8</value> </list> </property> </bean> <! -- FreeMarker viewResolver default view --> <bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/> <property name="contentType" value="text/html; charset=utf-8"/> <property name="requestContextAttribute" value="rc"/> <property name="cache" value="false"/> <property name="viewNames" value="*.html" /> <property name="suffix" value=""/> <property name="order" value="0"/> </bean> <bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="templateLoaderPath" value="/WEB-INF/page/"/> <property name="defaultEncoding" value ="UTF-8"></property> </bean> <! < MVC :resources location="/static/" mapping="/static/**"></ MVC :resources> </beans>Copy the code

Write in the last

In fact, I feel that in addition to working hard to learn some knowledge points, it is also very important to sort out records. It may have no effect in the early stage, but the importance becomes more and more obvious in the later stage, and sometimes it will affect your job promotion

Pay attention to me, we work together to grow