ソースを参照

spring.xml去除

demon 8 年 前
コミット
fde3983c02

+ 1 - 1
src/main/java/com/yihu/hos/tenant/model/IdModel.java

@ -3,7 +3,7 @@
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.hos.tenant.model;
package com.yihu.hos.web.framework.model;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

+ 170 - 135
src/main/java/com/yihu/hos/config/BeanConfig.java

@ -1,7 +1,34 @@
package com.yihu.hos.config;
import com.yihu.hos.interceptor.AuditInterceptor;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.core.env.Environment;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate4.HibernateTemplate;
import org.springframework.orm.hibernate4.HibernateTransactionManager;
import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
/**
 * @author HZY
@ -9,149 +36,157 @@ import org.springframework.context.annotation.ImportResource;
 * Created at 2016/8/5.
 */
@Configuration
//@EnableTransactionManagement
//@ComponentScan("com.yihu.hos")
@ImportResource({"classpath:spring/applicationContext.xml"}) //applicationContext相关bean创建
public class BeanConfig{
//    private Environment environment;
//    private RelaxedPropertyResolver datasourcePropertyResolver;
//    private RelaxedPropertyResolver hibernatePropertyResolver;
//
//
//    //从application.yml中读取资源
//    @Override
//    public void setEnvironment(Environment environment) {
//        this.environment = environment;
//        this.datasourcePropertyResolver = new RelaxedPropertyResolver(environment, "spring.datasource.");
//        this.hibernatePropertyResolver = new RelaxedPropertyResolver(environment, "spring.jpa.");
//
//    }
//
//    //datasource 池方式
////    @Bean(initMethod = "init", destroyMethod = "close")
////    public DataSource dataSource() throws SQLException {
////        if (StringUtils.isEmpty(datasourcePropertyResolver.getProperty("url"))) {
////            System.out.println("Your database connection pool configuration is incorrect!" +
////                    " Please check your Spring profile, current profiles are:"+
////                    Arrays.toString(environment.getActiveProfiles()));
////            throw new ApplicationContextException(
////                    "Database connection pool is not configured correctly");
////        }
////        DruidDataSource druidDataSource = new DruidDataSource();
////        druidDataSource.setUrl(datasourcePropertyResolver.getProperty("url"));
////        druidDataSource.setUsername(datasourcePropertyResolver
////                .getProperty("username"));
////        druidDataSource.setPassword(datasourcePropertyResolver
////                .getProperty("password"));
////        druidDataSource.setInitialSize(1);
////        druidDataSource.setMinIdle(1);
////        druidDataSource.setMaxActive(20);
////        druidDataSource.setMaxWait(60000);
////        druidDataSource.setTimeBetweenEvictionRunsMillis(60000);
////        druidDataSource.setMinEvictableIdleTimeMillis(300000);
////        druidDataSource.setValidationQuery("SELECT 'x'");
////        druidDataSource.setTestWhileIdle(true);
////        druidDataSource.setTestOnBorrow(false);
////        druidDataSource.setTestOnReturn(false);
////        return druidDataSource;
////    }
//
//    @Bean( destroyMethod = "close")
//    public BasicDataSource dataSource() throws SQLException {
//        if (StringUtils.isEmpty(datasourcePropertyResolver.getProperty("url"))) {
//            System.out.println("Your database connection pool configuration is incorrect!" +
//                    " Please check your Spring profile, current profiles are:"+
//                    Arrays.toString(environment.getActiveProfiles()));
//            throw new ApplicationContextException(
//                    "Database connection pool is not configured correctly");
//        }
//        BasicDataSource dataSource = new BasicDataSource();
//        dataSource.setUrl(datasourcePropertyResolver.getProperty("url"));
//        dataSource.setUsername(datasourcePropertyResolver.getProperty("username"));
//        dataSource.setPassword(datasourcePropertyResolver.getProperty("password"));
//        dataSource.setInitialSize(datasourcePropertyResolver.getProperty("initial-size", Integer.class));
//        dataSource.setMaxTotal(datasourcePropertyResolver.getProperty("max-total", Integer.class));
//        dataSource.setMinIdle(datasourcePropertyResolver.getProperty("min-idle",Integer.class));
//        dataSource.setMaxIdle(datasourcePropertyResolver.getProperty("max-idle",Integer.class));
//        dataSource.setValidationQuery(datasourcePropertyResolver.getProperty("validation-query"));
//        dataSource.setRemoveAbandonedTimeout(55);
//        dataSource.setTestOnBorrow(datasourcePropertyResolver.getProperty("test-on-borrow",Boolean.class));
//        return dataSource;
//    }
//
//    //sessionFactory
@EnableTransactionManagement
@ComponentScan("com.yihu.hos")
//@ImportResource({"classpath:spring/applicationContext.xml"}) //applicationContext相关bean创建
public class BeanConfig  implements EnvironmentAware {
//    @Autowired
//    BasicDataSource dataSource;
    @Value("${spring.jpa.hibernate.dialect}")
    private String dialect;
    @Value("${spring.jpa.format-sql}")
    private String formatSql;
    @Value("${spring.jpa.show-sql}")
    private String showSql;
    private Environment environment;
    private Map<String , Object> hibernatePropertyResolver;
    private Map<String , Object> datasourcePropertyResolver;
    //从application.yml中读取资源
    @Override
    public void setEnvironment(Environment environment) {
        this.environment = environment;
        datasourcePropertyResolver = new RelaxedPropertyResolver(environment).getSubProperties("spring.datasource.");
        this.hibernatePropertyResolver = new RelaxedPropertyResolver(environment).getSubProperties("spring.jpa.");
    }
    //sessionFactory
//    @Bean
//    public LocalSessionFactoryBean sessionFactory() throws SQLException {
//        LocalSessionFactoryBean localSessionFactoryBean = new LocalSessionFactoryBean();
//        localSessionFactoryBean.setDataSource(this.dataSource());
//        localSessionFactoryBean.setDataSource(this.dataSource);
//        Properties properties1 = new Properties();
//        properties1.setProperty("hibernate.dialect",hibernatePropertyResolver.getProperty("hibernate.dialect"));
//        properties1.setProperty("hibernate.show_sql",hibernatePropertyResolver.getProperty("show-sql"));
//        properties1.setProperty("hibernate.format_sql",hibernatePropertyResolver.getProperty("format-sql"));
//        properties1.setProperty("hibernate.dialect",hibernatePropertyResolver.get("hibernate.dialect").toString());
//        properties1.setProperty("hibernate.show_sql",hibernatePropertyResolver.get("show-sql").toString());
//        properties1.setProperty("hibernate.format_sql",hibernatePropertyResolver.get("format-sql").toString());
//        localSessionFactoryBean.setHibernateProperties(properties1);
//        localSessionFactoryBean.setPackagesToScan("com.yihu.hos.standard.model");
//        localSessionFactoryBean.setPackagesToScan("com.yihu.hos.*.model");
//        ResourceLoader resourceLoader = new DefaultResourceLoader();
//        Resource resource = resourceLoader.getResource("classpath:resource/");
//        localSessionFactoryBean.setMappingDirectoryLocations(resource);
////        localSessionFactoryBean.setPackagesToScan("*");
//        return localSessionFactoryBean;
//    }
//
//    //txManager事务开启
//    @Bean
//    public HibernateTransactionManager txManager() throws SQLException {
//        HibernateTransactionManager hibernateTransactionManager = new HibernateTransactionManager();
//        hibernateTransactionManager.setSessionFactory(sessionFactory().getObject());
//        return hibernateTransactionManager;
//    }
//
//    //文经上传
//    @Bean
//    public CommonsMultipartResolver multipartResolver(){
//        return new CommonsMultipartResolver();
//    }
//
//    //国际化配置
//    @Bean
//    public ResourceBundleMessageSource messageSource(){
//        ResourceBundleMessageSource messageSource =new ResourceBundleMessageSource();
//        messageSource.setBasenames("text/message");
//        messageSource.setDefaultEncoding("UTF-8");
//        return messageSource;
//    }
//
//    @Bean
//    public CookieLocaleResolver localeResolver(){
//        CookieLocaleResolver localeResolver = new CookieLocaleResolver();
//        localeResolver.setCookieName("Language");
//        localeResolver.setCookieMaxAge(604800);
//        localeResolver.setDefaultLocale(new Locale("zh_CN"));
//        return localeResolver;
//    }
//
//    @Bean
//    public LocaleChangeInterceptor localeChangeInterceptor(){
//        return new LocaleChangeInterceptor();
//    }
//
//    @Bean
//    public JdbcTemplate jdbcTemplate(){
//        JdbcTemplate jdbcTemplate = new JdbcTemplate();
//        try {
//            jdbcTemplate.setDataSource(this.dataSource());
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
//        return jdbcTemplate;
//    }
//
//    //Hibernate模版配置
//    @Bean
//    public HibernateTemplate hibernateTemplate() throws SQLException {
//        HibernateTemplate hibernateTemplate = new HibernateTemplate();
//        hibernateTemplate.setSessionFactory(this.sessionFactory().getObject());
//        return hibernateTemplate;
//    }
    @Bean
    public LocalSessionFactoryBean sessionFactory()   {
        LocalSessionFactoryBean localSessionFactoryBean = new LocalSessionFactoryBean();
        localSessionFactoryBean.setDataSource(dataSource());
        Properties properties1 = new Properties();
        properties1.setProperty("hibernate.dialect",dialect);
        properties1.setProperty("hibernate.show_sql", showSql);
        properties1.setProperty("hibernate.format_sql",formatSql);
        localSessionFactoryBean.setHibernateProperties(properties1);
        localSessionFactoryBean.setPackagesToScan("com.yihu.hos.*.model");
        ResourceLoader resourceLoader = new DefaultResourceLoader();
        Resource resource = resourceLoader.getResource("resource/");
        localSessionFactoryBean.setMappingDirectoryLocations(resource);
        //设置拦截器
        localSessionFactoryBean.setEntityInterceptor(this.auditInterceptor());
        return localSessionFactoryBean;
    }
    @Bean( destroyMethod = "close")
    public BasicDataSource dataSource() {
        if (StringUtils.isEmpty(datasourcePropertyResolver.get("url").toString())) {
            System.out.println("Your database connection pool configuration is incorrect!" +
                    " Please check your Spring profile, current profiles are:"+
                    Arrays.toString(environment.getActiveProfiles()));
            throw new ApplicationContextException(
                    "Database connection pool is not configured correctly");
        }
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setUrl(datasourcePropertyResolver.get("url").toString());
        dataSource.setUsername(datasourcePropertyResolver.get("username").toString());
        dataSource.setPassword(datasourcePropertyResolver.get("password").toString());
        dataSource.setInitialSize((Integer)datasourcePropertyResolver.get("initial-size"));
        dataSource.setMaxTotal((Integer)datasourcePropertyResolver.get("max-total"));
        dataSource.setMinIdle((Integer)datasourcePropertyResolver.get("min-idle"));
        dataSource.setMaxIdle((Integer)datasourcePropertyResolver.get("max-idle"));
        dataSource.setValidationQuery(datasourcePropertyResolver.get("validation-query").toString());
        dataSource.setRemoveAbandonedTimeout(55);
        dataSource.setTestOnBorrow((boolean)datasourcePropertyResolver.get("test-on-borrow"));
        return dataSource;
    }
    //txManager事务开启
    @Bean
    public HibernateTransactionManager txManager() throws SQLException {
        HibernateTransactionManager hibernateTransactionManager = new HibernateTransactionManager();
        LocalSessionFactoryBean sessionFactoryBean = this.sessionFactory();
        hibernateTransactionManager.setSessionFactory(sessionFactoryBean.getObject());
        return hibernateTransactionManager;
    }
    //文经上传
    @Bean
    public CommonsMultipartResolver multipartResolver(){
        return new CommonsMultipartResolver();
    }
    //国际化配置
    @Bean
    public ResourceBundleMessageSource messageSource(){
        ResourceBundleMessageSource messageSource =new ResourceBundleMessageSource();
        messageSource.setBasenames("text/message");
        messageSource.setDefaultEncoding("UTF-8");
        return messageSource;
    }
    @Bean
    public CookieLocaleResolver localeResolver(){
        CookieLocaleResolver localeResolver = new CookieLocaleResolver();
        localeResolver.setCookieName("Language");
        localeResolver.setCookieMaxAge(604800);
        localeResolver.setDefaultLocale(new Locale("zh_CN"));
        return localeResolver;
    }
    @Bean
    public LocaleChangeInterceptor localeChangeInterceptor(){
        return new LocaleChangeInterceptor();
    }
    @Bean
    public JdbcTemplate jdbcTemplate(){
        JdbcTemplate jdbcTemplate = new JdbcTemplate();
        try {
            jdbcTemplate.setDataSource(this.dataSource());
            jdbcTemplate.setLazyInit(false);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jdbcTemplate;
    }
    //Hibernate模版配置
    @Bean
    public HibernateTemplate hibernateTemplate() throws SQLException {
        HibernateTemplate hibernateTemplate = new HibernateTemplate();
        LocalSessionFactoryBean sessionFactory = this.sessionFactory();
        hibernateTemplate.setSessionFactory(sessionFactory.getObject());
        return hibernateTemplate;
    }
    @Bean
    public AuditInterceptor auditInterceptor(){
        return new AuditInterceptor();
    }
}

+ 16 - 0
src/main/java/com/yihu/hos/standard/model/adapter/AdapterSchemeModel.java

@ -2,6 +2,7 @@ package com.yihu.hos.standard.model.adapter;
import com.yihu.hos.web.framework.model.Result;
import javax.persistence.*;
import java.io.Serializable;
/**
@ -9,27 +10,42 @@ import java.io.Serializable;
 *
 * @Created by lingfeng 2015/12/23.
 */
@Entity
@Table(name = "adapter_scheme")
public class AdapterSchemeModel extends Result implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    @Column(name="parent_id")
    private Integer parentId;
    @Column(name="name")
    private String name;
    @Column(name="type")
    private String type;
    @Column(name="description")
    private String description;
    @Column(name="status")
    private Integer status;
    @Column(name="std_id")
    private Integer stdId;
    @Column(name="std_version")
    private String stdVersion;
    @Column(name="adapter_std_id")
    private Integer adapterStdId;
    @Column(name="adapter_std_version")
    private String adapterStdVersion;
    @Column(name="adapter_publisher_org_code")
    private String adapterPublisherOrgCode;
    public Integer getId() {

+ 13 - 0
src/main/java/com/yihu/hos/standard/model/adapter/AdapterSchemeVersionModel.java

@ -2,6 +2,7 @@ package com.yihu.hos.standard.model.adapter;
import com.yihu.hos.web.framework.model.Result;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@ -10,23 +11,35 @@ import java.util.Date;
 *
 * @created lingfeng 2015/12/23.
 */
@Entity
@Table(name = "adapter_scheme_version")
public class AdapterSchemeVersionModel extends Result implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    @Column(name="scheme_id")
    private Integer schemeId;
    @Column(name="name")
    private String name;
    @Column(name="version")
    private String version;
    @Column(name="publish_time")
    private Date publishTime;
    @Column(name="publish_user")
    private String publishUser;
    @Column(name="base_version")
    private String baseVersion;
    @Column(name="publish_status")
    private Integer publishStatus;
    @Column(name="path")
    private String path;
    public AdapterSchemeVersionModel(){

+ 3 - 1
src/main/java/com/yihu/hos/tenant/model/TenantModel.java

@ -1,5 +1,7 @@
package com.yihu.hos.tenant.model;
import com.yihu.hos.web.framework.model.IdModel;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -13,7 +15,7 @@ import java.util.Date;
 */
@Entity
@Table(name = "tenant")
public class TenantModel extends IdModel{
public class TenantModel extends IdModel {
    private String code;
    private String name;

+ 44 - 34
src/main/resources/application.yml

@ -20,26 +20,27 @@ spring:
---
spring:
  profiles: dev
  #SAAS管理员账号,暂时配置在此处
  administrators: jkzl
#  datasource:
#      driverClassName: com.mysql.jdbc.Driver
#      url: jdbc:mysql://192.168.1.220:3306/esb?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
#      username: hos2
#      password: hos2
#      test-on-borrow: true
#      validation-query: SELECT 1
#      test-while-idle: true
#      max-total: 100
#      default-auto-commit: true
#      max-idle: 30
#      min-idle: 10
#      initial-size: 10
#  jpa:
#    database-platform: org.hibernate.dialect.MySQL5Dialect
#    hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
#    format-sql: true
#    show-sql: true
  #SAAS管理员账号,暂时配置在此处
  datasource:
      driverClassName: com.mysql.jdbc.Driver
      url: jdbc:mysql://192.168.1.220:8066/global_db?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
      username: hos
      password: 123456
      test-on-borrow: true
      validation-query: SELECT 1
      test-while-idle: true
      max-total: 100
      default-auto-commit: true
      max-idle: 50
      min-idle: 20
      initial-size: 10
  jpa:
    database-platform: org.hibernate.dialect.MySQL5Dialect
    hibernate:
      dialect: org.hibernate.dialect.MySQL5Dialect
    format-sql: true
    show-sql: false
  data:
    mongodb:
      host: 172.19.103.86
@ -52,6 +53,8 @@ spring:
    user: admin
    password: admin
    pooled: false
  aop:
    proxy-target-class: true
---
spring:
  profiles: test
@ -83,6 +86,26 @@ spring:
  #SAAS管理员账号,暂时配置在此处
  administrators: jkzl
  profiles: lfq
  #SAAS管理员账号,暂时配置在此处
  datasource:
      driverClassName: com.mysql.jdbc.Driver
      url: jdbc:mysql://192.168.1.220:8066/global_db?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
      username: hos
      password: 123456
      test-on-borrow: true
      validation-query: SELECT 1
      test-while-idle: true
      max-total: 100
      default-auto-commit: true
      max-idle: 50
      min-idle: 20
      initial-size: 10
  jpa:
    database-platform: org.hibernate.dialect.MySQL5Dialect
    hibernate:
      dialect: org.hibernate.dialect.MySQL5Dialect
    format-sql: true
    show-sql: false
  data:
    mongodb:
      host: 172.19.103.86
@ -96,18 +119,5 @@ spring:
    user: admin
    password: admin
    pooled: false
---
spring:
  profiles: hzy
  data:
    mongodb:
      host: 172.19.103.86
      port: 27017
      username: esb
      password: esb
      authenticationDatabase: admin
  activemq:
    broker-url: tcp://172.19.103.86:61616?wireFormat.maxInactivityDuration=0
    user: admin
    password: admin
    pooled: false
  aop:
    proxy-target-class: true

+ 0 - 20
src/main/resources/resource/AdapterScheme.hbm.xml

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="com.yihu.hos.standard.model.adapter.AdapterSchemeModel" table="adapter_scheme">
        <id name="id" column="id">
            <generator class="increment"/>
        </id>
        <property name="parentId" column="parent_id"/>
        <property name="name" column="name"/>
        <property name="type" column="type"/>
        <property name="description" column="description"/>
        <property name="status" column="status"/>
        <property name="stdId" column="std_id"/>
        <property name="stdVersion" column="std_version"/>
        <property name="adapterStdId" column="adapter_std_id"/>
        <property name="adapterStdVersion" column="adapter_std_version"/>
        <property name="adapterPublisherOrgCode" column="adapter_publisher_org_code"/>
    </class>
</hibernate-mapping>

+ 0 - 121
src/main/resources/spring/applicationContext.xml

@ -1,121 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans default-lazy-init="false"
       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"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"
       xmlns:aop="http://www.springframework.org/schema/aop">
    <!--业务Beans, 使用注解方式配置-->
    <context:component-scan base-package="com.yihu.hos">
    </context:component-scan>
    <!--====================返回为null的时候转“”==========================-->
    <mvc:annotation-driven>
        <mvc:message-converters register-defaults="true">
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="objectMapper">
                    <bean class="com.fasterxml.jackson.databind.ObjectMapper">
                        <property name="serializationInclusion">
                            <value type="com.fasterxml.jackson.annotation.JsonInclude.Include">NON_NULL</value>
                        </property>
                    </bean>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
    <!--Hibernate 数据库配置-->
    <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://192.168.1.220:8066/global_db?useUnicode=true&amp;characterEncoding=UTF-8"/>
        <property name="username" value="hos"/>
        <property name="password" value="123456"/>
        <property name="initialSize" value="1"/>
        <property name="maxTotal" value="100"/>
        <property name="maxIdle" value="50"/>
        <property name="minIdle" value="20"/>
        <property name="validationQuery" value="SELECT 1"/>
        <property name="testOnBorrow" value="true"/>
        <property name="removeAbandonedTimeout" value="55"/>
    </bean>
    <bean id="cacheIntercepter" class="com.yihu.hos.interceptor.AuditInterceptor" />
    <!--Hibernate 会话管理器配置-->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="entityInterceptor">
            <ref bean="cacheIntercepter"/>
        </property>
        <property name="packagesToScan">
            <list>
                <!-- 可以加多个包 -->
                <value>com.yihu.hos.*.model</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
                hibernate.show_sql=false
                hibernate.format_sql=true
            </value>
        </property>
        <property name="mappingLocations">
            <list>
                <!-- <value>classpath:hbm/*.hbm.xml</value>-->
                <value>classpath:resource/*.hbm.xml</value>
            </list>
        </property>
    </bean>
    <!-- 将多个配置文件读取到容器中,交给Spring管理 -->
    <!--Hibernate 事务配置-->
    <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/>
    <!--文件上传支持-->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
    <!--国际化配置-->
    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <description>Message Sources</description>
        <property name="basenames">
            <list>
                <value>text/message</value>
            </list>
        </property>
        <property name="defaultEncoding" value="UTF-8"/>
    </bean>
    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
        <property name="cookieMaxAge" value="604800"/>
        <property name="defaultLocale" value="zh_CN"/>
        <property name="cookieName" value="Language"></property>
    </bean>
    <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource"/>
    </bean>
    <!--Hibernate模版配置 -->
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <!--<bean id="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" scope="singleton">-->
        <!--<property name="dataSource" ref="dataSource"/>-->
        <!--<property name="configLocation" value="classpath:/config/quartz.properties" />-->
        <!--<property name="autoStartup" value="true"/>-->
    <!--</bean>-->
</beans>

+ 0 - 61
src/main/resources/spring/dispatcher-servlet.xml

@ -1,61 +0,0 @@
<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"
       xmlns:p="http://www.springframework.org/schema/p"
       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">
    <context:component-scan base-package="com.yihu.hos">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
    </context:component-scan>
    <!-- 允许访问指定路径下的静态资源 -->
    <mvc:resources location="develop/" mapping="/develop/**" />
    <mvc:resources location="WEB-INF/" mapping="/WEB-INF/**" />
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/ehr/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
    <bean id="tilesViewResolver" class="org.springframework.web.servlet.view.tiles3.TilesViewResolver" p:order="1">
    </bean>
    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>file:../webapp/WEB-INF/ehr/commons/layout/layout.xml</value>
            </list>
        </property>
    </bean>
    <!--api接口系统请求参数,拦截器(目前只做了非空判断)
    <mvc:interceptors>
        <mvc:interceptor>
            <mvc:mapping path="/rest" />
            <bean class="com.yihu.ha.interceptor.RestUrlInterceptor" />
        </mvc:interceptor>
    </mvc:interceptors>-->
    <!-- 自定义json转换类(时间类型) -->
    <mvc:annotation-driven>
        <mvc:message-converters>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="objectMapper">
                    <bean class="com.fasterxml.jackson.databind.ObjectMapper">
                        <property name="dateFormat">
                            <bean class="java.text.SimpleDateFormat">
                                <constructor-arg type="java.lang.String" value="yyyy-MM-dd HH:mm:ss"/>
                            </bean>
                        </property>
                    </bean>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
</beans>