项目通用配置xml
阅读原文时间:2023年07月11日阅读:1

SqlMapperClient.xml




/src/main/resources/spring/applicationContext-dao.xml


http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

<!-- 配置数据源 dataSource -->  
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">  
    <property name="url" value="${jdbc.url}" />  
    <property name="username" value="${jdbc.username}" />  
    <property name="password" value="${jdbc.password}" />  
    <property name="driverClassName" value="${jdbc.driver}" />  
    <property name="maxActive" value="" />  
    <property name="minIdle" value="" />  
</bean>

<!-- 创建mybatis的上下文对象  -->  
<bean class="org.mybatis.spring.SqlSessionFactoryBean">  
    <property name="dataSource">  
        <ref bean="dataSource"/>  
    </property>  
    <property name="configLocation">  
        <value>classpath:mybatis/SqlMapperClient.xml</value>  
    </property>  
</bean>

<!-- 扫描mybatis的接口与映射配置文件 -->  
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
    <property name="basePackage" value="com.bjsxt.mapper"/>  
</bean>  

/src/main/resources/spring/applicationContext-Jedis.xml


http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">



192.168.70.145

<!-- JedislCluster -->  
<bean id="jedisCluster" class="redis.clients.jedis.JedisCluster">  
    <constructor-arg name="nodes">  
        <set>  
            <bean class="redis.clients.jedis.HostAndPort">  
                <constructor-arg name="host">  
                 <value>192.168.70.145</value>  
                </constructor-arg>  
                <constructor-arg name="port">  
                  <value></value>  
                </constructor-arg>  
            </bean>  
            <bean class="redis.clients.jedis.HostAndPort">  
                <constructor-arg name="host">  
                 <value>192.168.70.145</value>  
                </constructor-arg>  
                <constructor-arg name="port">  
                  <value></value>  
                </constructor-arg>  
            </bean>  
            <bean class="redis.clients.jedis.HostAndPort">  
                <constructor-arg name="host">  
                 <value>192.168.70.145</value>  
                </constructor-arg>  
                <constructor-arg name="port">  
                  <value></value>  
                </constructor-arg>  
            </bean>  
            <bean class="redis.clients.jedis.HostAndPort">  
                <constructor-arg name="host">  
                 <value>192.168.70.145</value>  
                </constructor-arg>  
                <constructor-arg name="port">  
                  <value></value>  
                </constructor-arg>  
            </bean>  
            <bean class="redis.clients.jedis.HostAndPort">  
                <constructor-arg name="host">  
                 <value>192.168.70.145</value>  
                </constructor-arg>  
                <constructor-arg name="port">  
                  <value></value>  
                </constructor-arg>  
            </bean>  
            <bean class="redis.clients.jedis.HostAndPort">  
                <constructor-arg name="host">  
                 <value>192.168.70.145</value>  
                </constructor-arg>  
                <constructor-arg name="port">  
                  <value></value>  
                </constructor-arg>  
            </bean>  
        </set>  
    </constructor-arg>  
    <constructor-arg name="poolConfig">  
        <ref bean="poolconfig"/>  
    </constructor-arg>  
</bean>

<!-- JedisDaoImplCluster -->  
<!-- <bean id="jedisDaoImplCluster" class="com.bjsxt.jedisdao.impl.JedisDaoImplCluster"></bean> -->  

/src/main/resources/spring/applicationContext-service.xml


http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

/src/main/resources/spring/applicationContext-trans.xml


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">





springmvc.xml


http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

   <!-- 注册两个新对象 主要是为了来处理springmvc中的其他anntation 如:@requestmapping -->  
   <mvc:annotation-driven/>

   <!-- 视图解析器 -->  
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
    <property name="prefix" value="/WEB-INF/jsp/" /><!-- jsp所在的前缀 -->  
    <property name="suffix" value=".jsp" />  
</bean>  
<!-- 配置静态资源映射 -->  
<mvc:resources location="/WEB-INF/css/" mapping="/css/\*\*"/>  
<mvc:resources location="/WEB-INF/js/" mapping="/js/\*\*"/>  

web.xml


http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app\_3\_0.xsd" id="WebApp\_ID" version="3.0">

contextConfigLocation classpath:spring/applicationContext-*.xml
org.springframework.web.context.ContextLoaderListener

<!-- 配置springmvc -->  
<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:spring/springmvc.xml</param-value>  
    </init-param>  
    <load-on-startup></load-on-startup>  
</servlet>  
<servlet-mapping>  
    <servlet-name>springmvc</servlet-name>  
    <url-pattern>/</url-pattern>  
</servlet-mapping>

<filter>  
    <filter-name>encoding</filter-name>  
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
    <init-param>  
        <param-name>encoding</param-name>  
        <param-value>utf-</param-value>  
    </init-param>  
</filter>  
<filter-mapping>  
    <filter-name>encoding</filter-name>  
    <url-pattern>/\*</url-pattern>  
</filter-mapping>

<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>  

db.properties

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/world?characterEncoding=utf-8
jdbc.username=root
jdbc.password=root

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器