jav中的各种配置文件

Spring配置文件


<beans default-lazy-init="true"
    xmlns="http://www.springframework.org/schema/beans" 
    xmlns:p="http://www.springframework.org/schema/p"
    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"
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xsi:schemaLocation="  
       http://www.springframework.org/schema/beans   
       http://www.springframework.org/schema/beans/spring-beans-4.3.xsd  
       http://www.springframework.org/schema/mvc   
       http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd   
       http://www.springframework.org/schema/tx   
       http://www.springframework.org/schema/tx/spring-tx-4.3.xsd   
       http://www.springframework.org/schema/aop 
       http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
       http://www.springframework.org/schema/util 
       http://www.springframework.org/schema/util/spring-util-4.3.xsd
       http://www.springframework.org/schema/data/jpa 
       http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-4.3.xsd" > 

    
    <context:component-scan base-package="com.jt" />
    
    <mvc:annotation-driven />
    
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        
        <property name="prefix" value="/WEB-INF/pages/" />
        <property name="suffix" value=".html">property>
    bean>  
    
    <util:properties id="cfg" location="classpath:config.properties"/>
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
        destroy-method="close" init-method="init" lazy-init="true">
        <property name="driverClassName" value="#{cfg.driver}" />
        <property name="url" value="#{cfg.url}" />
        <property name="username" value="#{cfg.username}" />
        <property name="password" value="#{cfg.password}" />
    bean>
    
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
       <property name="dataSource" ref="dataSource"/>
       <property name="configLocation" 
                 value="classpath:mybatis-configs.xml"/>
    bean>
    
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage"
                  value="com.jt.**.dao "/>
    bean>
    
     <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
         
         <property name="securityManager" ref="securityManager"/>
          
        <property name="loginUrl" value="/loginUI.do">property>
         
         
         
         
         <property name="filterChainDefinitions">
             <value>
                 
                 /bower_components/** = anon
                 /build/** = anon
                 /dist/** = anon
                 /plugins/** = anon
                 /doLogin.do = anon
                 
                 /logout.do = logout  
                 
                 /** = authc
             value>
         property>
     bean>

     
     <bean id="securityManager" 
           class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
         <property name="cacheManager" ref="cacheManager"/>
         <property name="realm" ref="userRealm">property>
     bean>

     
    <bean id="userRealm" class="com.jt.sys.service.realm.ShiroUserRealm">
        
        <property name="credentialsMatcher">
            <bean class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
                <property name="hashAlgorithmName" value="MD5"/>
                
            bean>
        property>
    bean>

    <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
        
        
        <property name="cacheManagerConfigFile" value="classpath:ehcache.xml"/> 
    bean>

    
    <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>

    
    <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
        depends-on="lifecycleBeanPostProcessor"/>
    <bean  class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
        <property name="securityManager" ref="securityManager"/>
    bean>

beans>

MyBatis核心配置文件



<configuration>
    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC" />
            <dataSource type="POOLED">
                <property name="driver" value="com.mysql.jdbc.Driver" />
                <property name="url" value="jdbc:mysql:///cgb1711" />
                <property name="username" value="root" />
                <property name="password" value="1234" />
            dataSource>
        environment>
    environments>
    
    <mappers>
        <mapper resource="mapper/BlogMapper.xml" />
    mappers>
configuration>

MyBatis映射文件




<mapper namespace="com.jt.blog.BlogDao">
    
    
    
    <select id="findBlogs" resultType="map">
        select * from blog
    select>
mapper>

Spring中web.xml配置


<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_2_5.xsd" version="2.5">
  <display-name>CGB-JT-SYS-V1.03display-name>
  <servlet>
    <servlet-name>dispatcherServletservlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>
    <init-param>
      <param-name>contextConfigLocationparam-name>
      <param-value>classpath:spring-*.xmlparam-value>
    init-param>
    <load-on-startup>1load-on-startup>
  servlet>
  <servlet-mapping>
    <servlet-name>dispatcherServletservlet-name>
    <url-pattern>*.dourl-pattern>
  servlet-mapping>
    <filter>
        <filter-name>DelegatingFilterProxyfilter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxyfilter-class>
        
        <init-param>
            <param-name>targetBeanNameparam-name>
            <param-value>shiroFilterparam-value>
        init-param>
    filter>
    <filter-mapping>
        <filter-name>DelegatingFilterProxyfilter-name>
        <url-pattern>/*url-pattern>
    filter-mapping>

web-app>

你可能感兴趣的:(配置文件)