SSM三大框架整合所需要的配置文件

 

 还有一个web.xml文件

1.web.xml文件的内容

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xmlns="http://xmlns.jcp.org/xml/ns/javaee"
 4     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
 5     http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
 6     id="WebApp_ID" version="3.1">
 7     <!-- 配置加载Spring文件的监听器-->    
 8     <context-param>
 9         <param-name>contextConfigLocation</param-name>
10         <param-value>classpath:applicationContext.xml</param-value>
11     </context-param>
12     <listener>
13         <listener-class>
14             org.springframework.web.context.ContextLoaderListener
15         </listener-class>
16     </listener>
17     <!-- 编码过滤器 -->
18     <filter>
19         <filter-name>encoding</filter-name>
20         <filter-class>
21             org.springframework.web.filter.CharacterEncodingFilter
22         </filter-class>
23         <init-param>
24             <param-name>encoding</param-name>
25             <param-value>UTF-8</param-value>
26         </init-param>
27     </filter>
28     <filter-mapping>
29         <filter-name>encoding</filter-name>
30         <url-pattern>*.action</url-pattern>
31     </filter-mapping>
32     <!-- 配置Spring MVC前端核心控制器 -->
33     <servlet>
34         <servlet-name>crm</servlet-name>
35         <servlet-class>
36             org.springframework.web.servlet.DispatcherServlet
37         </servlet-class>
38         <init-param>
39             <param-name>contextConfigLocation</param-name>
40             <param-value>classpath:springmvc-config.xml</param-value>
41         </init-param>
42         <!-- 配置服务器启动后立即加载Spring MVC配置文件 -->
43         <load-on-startup>1</load-on-startup>
44     </servlet>
45     <servlet-mapping>
46         <servlet-name>crm</servlet-name>
47         <url-pattern>*.action</url-pattern>
48     </servlet-mapping>
49     <!-- 系统默认页面 -->
50     <welcome-file-list>
51         <welcome-file>index.jsp</welcome-file>
52     </welcome-file-list>
53     
54     <servlet>
55     <servlet-name>VerifyCode</servlet-name>
56     <servlet-class>cn.edu.hnzj.utils.VerifyCodeServlet</servlet-class>
57   </servlet>
58   <servlet-mapping>
59     <servlet-name>VerifyCode</servlet-name>
60     <url-pattern>/verifyCode</url-pattern>
61   </servlet-mapping>
62 </web-app>

2.applicationContext.xml文件的内容

 1 <beans xmlns="http://www.springframework.org/schema/beans"
 2     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 3     xmlns:mvc="http://www.springframework.org/schema/mvc"
 4     xmlns:context="http://www.springframework.org/schema/context"
 5     xmlns:aop="http://www.springframework.org/schema/aop" 
 6     xmlns:tx="http://www.springframework.org/schema/tx"
 7     xsi:schemaLocation="http://www.springframework.org/schema/beans 
 8     http://www.springframework.org/schema/beans/spring-beans-4.3.xsd 
 9     http://www.springframework.org/schema/mvc 
10     http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd 
11     http://www.springframework.org/schema/context 
12     http://www.springframework.org/schema/context/spring-context-4.3.xsd 
13     http://www.springframework.org/schema/aop 
14     http://www.springframework.org/schema/aop/spring-aop-4.3.xsd 
15     http://www.springframework.org/schema/tx 
16     http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
17     <!--读取db.properties -->
18     <context:property-placeholder location="classpath:db.properties"/>
19     <!-- 配置数据源 -->
20     <bean id="dataSource" 
21          class="org.apache.commons.dbcp2.BasicDataSource">
22          <!--数据库驱动 -->
23          <property name="driverClassName" value="${jdbc.driver}" />
24          <!--连接数据库的url -->
25          <property name="url" value="${jdbc.url}" />
26          <!--连接数据库的用户名 -->
27          <property name="username" value="${jdbc.username}" />
28          <!--连接数据库的密码 -->
29          <property name="password" value="${jdbc.password}" />
30          <!--最大连接数 -->
31          <property name="maxTotal" value="${jdbc.maxTotal}" />
32          <!--最大空闲连接  -->
33          <property name="maxIdle" value="${jdbc.maxIdle}" />
34          <!--初始化连接数  -->
35          <property name="initialSize" value="${jdbc.initialSize}" />
36     </bean>
37     <!-- 事务管理器 -->
38     <bean id="transactionManager" class=
39     "org.springframework.jdbc.datasource.DataSourceTransactionManager">
40         <!-- 数据源 -->
41         <property name="dataSource" ref="dataSource" />
42     </bean>
43     <!-- 通知 -->
44     <tx:advice id="txAdvice" transaction-manager="transactionManager">
45         <tx:attributes>
46             <!-- 传播行为 -->
47             <tx:method name="save*" propagation="REQUIRED" />
48             <tx:method name="insert*" propagation="REQUIRED" />
49             <tx:method name="add*" propagation="REQUIRED" />
50             <tx:method name="create*" propagation="REQUIRED" />
51             <tx:method name="delete*" propagation="REQUIRED" />
52             <tx:method name="update*" propagation="REQUIRED" />
53             <tx:method name="find*" propagation="SUPPORTS" 
54                                            read-only="true" />
55             <tx:method name="select*" propagation="SUPPORTS" 
56                                            read-only="true" />
57             <tx:method name="get*" propagation="SUPPORTS" 
58                                            read-only="true" />
59         </tx:attributes>
60     </tx:advice>
61     <!-- 切面 -->
62     <aop:config>
63         <aop:advisor advice-ref="txAdvice"
64              pointcut="execution(* cn.edu.hnzj.service.*.*(..))" />
65     </aop:config>
66     <!-- 配置 MyBatis的工厂 -->
67     <bean class="org.mybatis.spring.SqlSessionFactoryBean">
68         <!-- 数据源 -->
69         <property name="dataSource" ref="dataSource" />
70         <!-- 配置MyBatis的核心配置文件所在位置 -->
71         <property name="configLocation" 
72                      value="classpath:mybatis-config.xml" />
73     </bean>
74     <!-- 接口开发,扫描 com.itheima.core.dao包 ,写在此包下的接口即可被扫描到 -->
75     <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
76         <property name="basePackage" value="cn.edu.hnzj.dao" />
77     </bean>
78     
79     <!-- 配置扫描@Service注解 -->
80     <context:component-scan base-package="cn.edu.hnzj.service"/>    
81 </beans>

3.mybatis-config.xml文件的内容

1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
3 "http://mybatis.org/dtd/mybatis-3-config.dtd">
4 <configuration>
5     <!-- 别名定义 -->
6     <typeAliases>
7         <package name="cn.edu.hnzj.po" />
8     </typeAliases>
9 </configuration>

4.springmvc-config.xml文件的内容

 1 <beans xmlns="http://www.springframework.org/schema/beans"
 2     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 3     xmlns:mvc="http://www.springframework.org/schema/mvc"
 4     xmlns:context="http://www.springframework.org/schema/context"
 5     xmlns:aop="http://www.springframework.org/schema/aop" 
 6     xmlns:tx="http://www.springframework.org/schema/tx"
 7     xsi:schemaLocation="http://www.springframework.org/schema/beans 
 8     http://www.springframework.org/schema/beans/spring-beans-4.3.xsd 
 9     http://www.springframework.org/schema/mvc 
10     http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd 
11     http://www.springframework.org/schema/context 
12     http://www.springframework.org/schema/context/spring-context-4.3.xsd 
13     http://www.springframework.org/schema/aop 
14     http://www.springframework.org/schema/aop/spring-aop-4.3.xsd 
15     http://www.springframework.org/schema/tx 
16     http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
17     <!-- 加载属性文件 -->
18     <context:property-placeholder 
19                location="classpath:resource.properties" />
20     <!-- 配置扫描器 -->
21     <context:component-scan 
22                base-package="cn.edu.hnzj.web.controller" />
23     <!-- 注解驱动:配置处理器映射器和适配器 -->
24     <mvc:annotation-driven />
25     <!--配置静态资源的访问映射,此配置中的文件,将不被前端控制器拦截 -->
26     <mvc:resources location="/js/" mapping="/js/**" />
27     <mvc:resources location="/css/" mapping="/css/**" />
28     <mvc:resources location="/fonts/" mapping="/fonts/**" />
29     <mvc:resources location="/images/" mapping="/images/**" />    
30     <!-- 配置视图解释器ViewResolver -->
31     <bean id="jspViewResolver" class=
32     "org.springframework.web.servlet.view.InternalResourceViewResolver">
33         <property name="prefix" value="/WEB-INF/jsp/" />
34         <property name="suffix" value=".jsp" />
35     </bean>    
36     
37     <!-- 配置拦截器 -->
38     
39     <!-- <mvc:interceptors>
40         <mvc:interceptor>
41             <mvc:mapping path="/**" />
42             <bean class="cn.edu.hnzj.interceptor.LoginInterceptor" />
43         </mvc:interceptor>
44     </mvc:interceptors>     -->
45 </beans>

5.db.properties文件的内容

1 jdbc.driver=com.mysql.jdbc.Driver
2 jdbc.url=jdbc:mysql://localhost:3306/boot_crm?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
3 jdbc.username=root
4 jdbc.password=123456
5 jdbc.maxTotal=30
6 jdbc.maxIdle=10
7 jdbc.initialSize=5

6.log4j.properties文件的内容

1 # Global logging configuration
2 log4j.rootLogger=ERROR, stdout
3 # MyBatis logging configuration...
4 log4j.logger.com.itheima.core=DEBUG
5 # Console output...
6 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
7 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
8 log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

7.resource.properties文件的内容

1 customer.from.type=002
2 customer.industry.type=001
3 customer.level.type=006

 

posted @ 2021-06-06 13:45  哥伦布杰  阅读(254)  评论(0)    收藏  举报