jetty jndi数据源
applicationContext.xml
<?xml version="1.0" encoding="utf-8"?>
<beans default-init-method="init" default-destroy-method="destroy"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
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/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath:database.properties"/>
</bean> <!-- jndi -->
<bean id="dataSourceMaster" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>wms</value>
</property>
<property name="resourceRef">
<value>true</value>
</property>
</bean> <bean id="dataSourceSlave" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>wmsSlave</value>
</property>
<property name="resourceRef">
<value>true</value>
</property>
</bean> <bean id="dataSource" class="com.yundaex.wms.config.DynamicDataSource" >
<property name="targetDataSources">
<map key-type="java.lang.String">
<entry value-ref="dataSourceMaster" key="dataSourceMaster"></entry>
<entry value-ref="dataSourceSlave" key="dataSourceSlave"></entry>
</map>
</property>
<property name="defaultTargetDataSource" ref="dataSourceMaster" >
</property>
</bean> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"></property>
</bean> <bean id="namedParameterJdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
<constructor-arg name="classicJdbcTemplate">
<ref bean="jdbcTemplate"/>
</constructor-arg>
</bean> <bean id="dynamicDataSourceAspect" class="com.yundaex.wms.config.aop.DynamicDataSourceAspect" /> <aop:config>
<aop:aspect ref="dynamicDataSourceAspect">
<aop:pointcut id="backMethod"
expression="execution(public * com.yundaex.wms..CompleteInboundNoticeBackToQimenDao.query*(..))
|| execution(public * com.yundaex.wms..InventoryCountReportToQimenDao.query*(..))
|| execution(public * com.yundaex.wms..OrderProcessReportToQimenDao.query*(..))
|| execution(public * com.yundaex.wms..OutboundNoticeConfirmBackToQimenDao.query*(..))
|| execution(public * com.yundaex.wms..ReturnOrderBackToQimenDao.query*(..))
|| execution(public * com.yundaex.wms..StockChangeReportToQimenDao.query*(..))
|| execution(public * com.yundaex.wms..CompleteInboundNoticeBackToCainiaoDao.query*(..))
|| execution(public * com.yundaex.wms..InventoryCountReportToCainiaoDao.query*(..))
|| execution(public * com.yundaex.wms..OrderProcessReportToCainiaoDao.query*(..))
|| execution(public * com.yundaex.wms..OutboundNoticeConfirmBackToCainiaoDao.query*(..))
"/>
<aop:around method="aroundMethod" pointcut-ref="backMethod"/>
</aop:aspect>
</aop:config> <mvc:annotation-driven />
<context:component-scan base-package="com.yundaex.wms" />
<!-- 配置事务管理 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean> <!-- 配置注解实现管理事务 -->
<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true" />
</beans>
WEB-INF文件夹下jetty-env.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<!-- 应用数据源 -->
<New id="wmsMasterDataSource" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>wms</Arg>
<Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">com.mysql.jdbc.Driver</Set>
<Set name="url">jdbc:mysql://10.19.105.161:3306/wms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true</Set>
<Set name="username">ggs</Set>
<Set name="password">UGTVDYTXVSIN</Set>
<Set name="maxActive">500</Set>
</New>
</Arg>
</New>
<New id="wmsSlaveDataSource" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>wmsSlave</Arg>
<Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">com.mysql.jdbc.Driver</Set>
<Set name="url">jdbc:mysql://10.19.105.184:3306/wms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true</Set>
<Set name="username">ggs</Set>
<Set name="password">ZPIOSVYLXMNI</Set>
<Set name="maxActive">500</Set>
</New>
</Arg>
</New>
<Set name="maxFormContentSize">2000000</Set>
</Configure>
jetty jndi数据源的更多相关文章
- jetty使用jndi数据源
之前将项目正常的数据源统一切换成jndi访问的形式(是将c3p0以mbean形式安装到jboss做的数据连接池), 本地测试用的jetty服务器,为了统一数据库访问部分,我也查看文档找到了jetty提 ...
- Tomcat下使用c3p0配置jndi数据源
下载c3p0包: 下载地址:https://sourceforge.net/projects/c3p0/files/?source=navbar 解压后得到包:c3p0-0.9.2.jar,mchan ...
- mysql连接超时与jndi数据源配置
昨天有运营说添加活动不能用了,我就看了一下后台日志,发现访问数据库是报错: at java.lang.Thread.run(Thread.java:722) Caused by: com.mysql. ...
- 为tomcat动态添加jndi数据源信息
我们在开发项目的时候,总要和数据库打交道,如何获取数据源,以什么样的方式来获取,成为了我们即简单又熟悉而且不得不注意的一个问题. 那么在这里我说三种获取数据源的常用方式: 一.通过配置文件来获取 首先 ...
- jboss EAP 6.2+ 通过代码控制JNDI数据源
通过Jboss提供的API,可以操控JBoss,效果跟在管理控制台手动操作完全一样,下面是示例代码: 一.pom.xml添加依赖项 <dependency> <groupId> ...
- Spring JDBCTemplate使用JNDI数据源
xml配置: <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverMana ...
- Tomcat 6 JNDI数据源详解
数据库连接池这个概念应该都不陌生,在Java中连接池也就是数据库的连接池,它是一种采用连接复用的思想避免多次连接造成资源的浪费机制. 最常见的连接池就是DBCP和C30P了,在tomcat中默认使用的 ...
- JNDI数据源局部配置(解决Cannot create JDBC driver of class '' for connect URL 'null')
最开始,我是借鉴 孤傲苍狼的JNDI教程去做的,他讲得很详细,但是坏处也就是因为他讲的太详细.查了很多书,都是建议说不要用全局去配置JNDI,一是要修改tomcat的server.xml,容易破坏to ...
- JNDI学习总结(一)——JNDI数据源的配置
一.数据源的由来 在Java开发中,使用JDBC操作数据库的四个步骤如下: ①加载数据库驱动程序(Class.forName("数据库驱动类");) ②连接数据库(Connec ...
随机推荐
- html中css的三种样式
在html中定义CSS样式的方法有三种,新建CSS文件 使用link 关联 这种是最常用的外部引用样式,第二种讲样式写在 head 头部里面 这种是页面样式 ,第三中样式直接写在行内 style里面 ...
- 维特比算法(Viterbi)
维特比算法(Viterbi) 维特比算法 编辑 维特比算法是一种动态规划算法用于寻找最有可能产生观测事件序列的-维特比路径-隐含状态序列,特别是在马尔可夫信息源上下文和隐马尔可夫模型中.术语“维特比路 ...
- c++类之间的关系
我们知道,表达方式分为很多种,对于同一种事物,比如爱情,画家用图画和色彩表达爱恋:音乐家用音符和节奏表达喜爱之情,作家用文字表现爱慕. 而程序员怎么办? 程序员构建类,用类来表达单身之苦.因此,类就是 ...
- aop 例子(annotation方式实现)
面向切面编程(也叫面向方面),可以通过预编译方式和运行期动态代理实现在不修改源代码的情况下给程序动态统一添加功能的一种技术.AOP实际是GoF设计模式的延续,设计模式孜孜不倦追求的是调用者和被调用者之 ...
- 如何在u盘上安装系统, (非安装盘)
在u盘中永久安装Fedora. 需要两个u盘(live usb), 一个系统镜像文件. 方法是: 用一个u盘作安装盘, 然后通过这个u盘把系统安装到另一个u盘上. 两个U盘上的文件都会被覆盖. 1. ...
- android自定义控件(六) 刷新
三种得到LinearInflater的方法 a. LayoutInflater inflater = getLayoutInflater(); b. LayoutInflater localinfla ...
- HihoCoder1651 : 小球染色([Offer收割]编程练习赛38)(DP的优化)
描述 小Ho面前有N个小球排成了一排.每个小球可以被染成M种颜色之一. 为了增强视觉效果,小Ho希望不存在连续K个或者K个以上的小球颜色一样. 你能帮小Ho计算出一共有多少种不同的染色方法么? 例如N ...
- HihoCoder1655 : 第K小最简真分数([Offer收割]编程练习赛39)(唯一分解+容斥定理+二分)(不错的数学题)
描述 给一个整数N,请你求出以N为分母的最简(既约)真分数中第K小的是多少? 输入 两个整数N个K. 对于30%的数据,1 <= N <= 1000000 对于100%的数据,1 < ...
- BZOJ_2813_奇妙的Fibonacci_线性筛
BZOJ_2813_奇妙的Fibonacci_线性筛 Description Fibonacci数列是这样一个数列: F1 = 1, F2 = 1, F3 = 2 . . . Fi = Fi-1 + ...
- 四维偏序 CDQ套CDQ
对CDQ深一步的理解 昨天做了一道CDQ,看了一堆CDQ可做的题,今天又做了一道四维偏序 感觉对CDQ的理解又深了一点,故来写一写现在自己对于CDQ的理解 CDQ其实就是实现了这样的一个问题的转化: ...