<?xml version="1.0" encoding="UTF-8"?>
<!– The contents of this file will be loaded for each web application –>
<context>
<!– Default set of monitored resources 172.16.5.28:KM–>
<watchedresource>WEB-INF/web.xml</watchedresource>
<resource
name="jdbc/test"
auth="Container"
type="javax.sql.DataSource"
maxactive="500"
maxidle="30"
maxwait="10000"
username="test"
password="test
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:orcl">
</resource>
</context>
然后附件中的文件就派上用场了(encrypt2.bat,commons-dbcp-1.2.2.jar和commons-pool-1.4.jar )
1、进入tomcat的安装目录: tomcatroot\common\lib
2、复制encrypt2.bat和commons-dbcp-1.2.2.jar和commons-pool-1.4.jar 进入该目录
3、进入cmd状态,切换入tomcatroot\common\lib目录 ,非常重要的是需要把webapps下面的各个应用里面的重复的jar删掉也就是要把所有的字母里面的commons-dbcp*.jar和commons-pool*.jar删掉
4、输入encrypt2.bat test (test)还是原密码,界面上会输出:
test 加密后: jAVagnSq2eQ=
test 解密后: test
5、修改context.xml password="jAVagnSq2eQ=" 并注意增加一行: factory="org.apache.commons.dbcp.BasicDataSourceFactory"
那么我们最后的配置就是:
<?xml version="1.0" encoding="UTF-8"?>
<!– The contents of this file will be loaded for each web application –>
<context>
<!– Default set of monitored resources 172.16.5.28:KM–>
<watchedresource>WEB-INF/web.xml</watchedresource>
<resource
name="jdbc/test"
auth="Container"
type="javax.sql.DataSource"
maxactive="500" maxidle="30"
maxwait="10000"
username="test"
password="jAVagnSq2eQ="
driverClassName="oracle.jdbc.OracleDriver"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
url="jdbc:oracle:thin:@localhost:1521:orcl">
</resource>
</context>
好了,重启试试吧