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 ...
随机推荐
- 分享知识-快乐自己:Hibernate框架常用API详解
1):Configuration配置对象 Configuration用于加载配置文件. 1): 调用configure()方法,加载src下的hibernate.cfg.xml文件 Configura ...
- Java_Time_01_获取当前时间
1. Date SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// ...
- Go丨语言学习笔记--switch
Java语言与Go语言的switch对比 Go语言 switch str { case "yes" : do something ... case "no" d ...
- Linux网络编程之select、poll、epoll的比较,以及epoll的水平触发(LT)和边缘触发(ET)
Linux的网络通信先后推出了select.poll.epoll三种模式. select有以下三个问题: (1)每次调用select,都需要把fd集合从用户态拷贝到内核态,这个开销在fd很多时会很大. ...
- bzoj3312
K个硬币,要买N个物品. 给定买的顺序,即按顺序必须是一路买过去,当选定买的东西物品序列后,付出钱后,货主是不会找零钱的.现希望买完所需要的东西后,留下的钱越多越好,如果不能完成购买任务,输出-1 $ ...
- Win 10 无法打开内核设备“\\.\Global\vmx86”
Win 10操作系统, VMWareWorkstation10 无法打开内核设备“\\.\Global\vmx86”: 系统找不到指定的文件.你想要在安装 VMware Workstation 前重启 ...
- java-01
二,八,十六进制到十进制的转换方法: 十进制到二,八,十六进制的转换方法: 2:标识符(掌握) (1)就是给类,接口,方法,变量等起名字的字符序列 (2)组成规则: A:英文大小写字母 B:数字 C: ...
- Words Gems
所有的东西都来自抄袭.来自学习.不同的是用新的方法做其他公司做过的事情.很多公司做同样的事情,但只有一家公司最成功.你要发现一个有需求的服务,并做得比别人更好,而不是比别人更早.
- jdbc代码
1.jdbcutiul的代码, package gz.itcast.util; import java.io.InputStream; import java.sql.Connection; impo ...
- AI-Info-Micron-Insight:通往完全自主之路
ylbtech-AI-Info-Micron-Insight:通往完全自主之路 1.返回顶部 1. 通往完全自主之路 自动驾驶汽车正在从未来梦想演变为当代现实,随着技术成熟,个人和公共交通将永远转变. ...