123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <?xml version="1.0" encoding="UTF-8"?>
- <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:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- 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.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd"
- default-lazy-init="false">
- <!-- DatabaseRecognizer: The key is database product name or its regular exp, and the value is to
- match the file name of spring/corebean/*-context-base.xml when the app startup -->
- <bean id="databaseRecognizer" class="com.primeton.dgs.kernel.core.web.springframework.DatabaseRecognizer">
- <property name="databaseNames">
- <map>
- <entry key="Microsoft SQL Server" value="SQLServer" />
- <entry key="DB2/.+" value="DB2" />
- <entry key="Oracle" value="Oracle" />
- <entry key="MySQL" value="MySQL" />
- <entry key="Teradata" value="Teradata" />
- <entry key="Informix Dynamic Server" value="Informix" />
- <entry key="GBase 8t V8.5 Database Server" value="Informix" />
- <entry key="KingbaseES" value="Kingbase" />
- <entry key="DM DBMS" value="DM" />
- <entry key="PostgreSQL" value="PostgreSQL"/>
- </map>
- </property>
- </bean>
- <!-- ============== DAO DEFINITIONS: HIBERNATE IMPLEMENTATIONS ================= -->
- <!-- 使用spring+hibernate处理oracle BLOB-->
- <bean id="sessionFactory" class="com.primeton.dgs.kernel.core.dao.hibernate.HibernateLocalSessionFactoryBean">
- <property name="databaseRecognizer" ref="databaseRecognizer" />
- <property name="dataSource" ref="dataSource" />
- <property name="mappingResources">
- <list >
- <value>META-INF/sqlxml/mysql/adapterSql.xml</value><!-- 加载hibernate模型配置文件,实际加载交由该具体类实现 -->
- </list>
- </property>
- <property name="hibernateProperties">
- <props>
- <prop key="hibernate.dialect">org.hibernate.dialect.MySQL57Dialect</prop>
- <prop key="hibernate.query.factory_class">org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory</prop>
- <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</prop>
- <prop key="hibernate.jdbc.batch_size">50</prop>
- <!-- <prop key="hibernate.jdbc.fetch_size">100</prop> --><!--由于oracle驱动的bug导致memory leak-->
- <prop key="hibernate.generate_statistics">true</prop>
- <prop key="hibernate.show_sql">false</prop>
- <prop key="hibernate.format_sql">false</prop>
- </props>
- </property>
- </bean>
- <bean id="hibernateDao" abstract="true">
- <property name="sessionFactory" ref="sessionFactory" />
- <property name="dataSource" ref="dataSource" />
- </bean>
- <bean id="seqService" class="com.primeton.dgs.kernel.common.app.base.bs.SequenceServiceImpl">
- </bean>
- <bean id="baseSequence" class="com.primeton.dgs.kernel.common.app.base.bs.SequenceServiceImpl"></bean>
- <bean id="daservice"
- class="com.primeton.dgs.kernel.core.dao.impl.DAOServiceImpl"
- parent="hibernateDao" />
- <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
- <property name="dataSource" ref="dataSource" />
- </bean>
- <bean id="statementSessionFactory" class="com.primeton.dgs.kernel.core.dao.hibernate.HibernateStatementSessionFactoryBean"
- init-method="init" destroy-method="destroy">
- <!-- 加载SQL资源文件,实际加载交由该具体类实现 -->
- <property name="statementResources" value="" />
- </bean>
- <!--JPA 配置 start-->
- <bean id="persistenceProvider" class="org.hibernate.jpa.HibernatePersistenceProvider"/>
- <!-- JPA entityManagerFactory -->
- <bean id="entityManagerFactory" class="com.primeton.dgs.kernel.core.dao.jpa.JpaContainerEntityManagerFactoryBean">
- <!-- 指定数据源 -->
- <property name="databaseRecognizer" ref="databaseRecognizer" />
- <property name="dataSource" ref="dataSource"/>
- <property name="persistenceUnitName" value="persistenceUnit"/>
- <property name="persistenceProvider" ref="persistenceProvider"/>
- <!-- 指定Entity实体类包路径 -->
- <property name="packagesToScan">
- <array>
- <value>com.primeton.dgs.entity</value>
- <value>org.gocom.coframe.model</value>
- </array>
- </property>
- <!-- 指定Jpa持久化实现厂商类,根据 databaseRecognizer 配置,大多数知名数据库都能自动配置。国产数据库或者其他无法确认的数据需要设置
- <property name="jpaVendorAdapter">
- <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
- <property name="generateDdl" value="false"/>
- <property name="database" value="MYSQL"/>
- <property name="databasePlatform" value="org.hibernate.dialect.MySQL57Dialect"/>
- <property name="showSql" value="false"/>
- </bean>
- </property>
- -->
- <!-- 指定JPA属性-->
- <property name="jpaPropertyMap">
- <map>
- <entry key="hibernate.show_sql" value="true" />
- <entry key="hibernate.query.substitutions" value="true 1, false 0"/>
- <entry key="hibernate.default_batch_fetch_size" value="16"/>
- <entry key="hibernate.max_fetch_depth" value="2"/>
- <entry key="hibernate.generate_statistics" value="false"/>
- <entry key="hibernate.bytecode.use_reflection_optimizer" value="true"/>
- <entry key="hibernate.cache.use_query_cache" value="false"/>
- <entry key="hibernate.cache.use_second_level_cache" value="false"/>
- <entry key="hibernate.enable_lazy_load_no_trans" value="true"/>
- <!--数据库字段名称映射规则 acb_id自动转abcId-->
- <entry key="hibernate.physical_naming_strategy" value="org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy" />
- <entry key="hibernate.implicit_naming_strategy" value="org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl"/>
- <!--<entry key="hibernate.hbm2ddl.auto" value="validate"/>-->
- </map>
- </property>
- </bean>
- <context:annotation-config />
- <context:component-scan base-package="org.gocom.coframe.**" />
- <!-- 默认的事务管理器,支持 Hibernate。 JPA 见 TransactionManagerConfigurer -->
- <bean id="defTransactionManager"
- class="org.springframework.orm.hibernate5.HibernateTransactionManager">
- <property name="dataSource" ref="dataSource" />
- <property name="sessionFactory" ref="sessionFactory" />
- </bean>
- <!-- Spring Context Helper -->
- <bean id="SpringContextHelper" class="com.primeton.dgs.kernel.core.common.SpringContextHelper" />
- <!-- Quartz针对不同的数据库有不同的配置在这里 -->
- <bean id="schedulerDelegate" abstract="true">
- <property name="quartzProperties">
- <props>
- </props>
- </property>
- </bean>
- <!--
- 消息服务,用于事件发布,如采集完成,发布事件:获得事件后更新缓存、汇总分析立即执行等
- add zhaopx at: 2019/11/11
- -->
- <bean id="eventMessageService" class="com.primeton.dgs.kernel.core.message.MessageService"
- init-method="init" destroy-method="shutdown">
- </bean>
- </beans>
|