开发者

Configure Spring to use specific version of a class

开发者 https://www.devze.com 2023-01-28 11:50 出处:网络
I have a java application that requires the latest commons-dbcp version (1.3) and it\'s db connection pool is configured by Spring. This application is but one of a list of applications in the same to

I have a java application that requires the latest commons-dbcp version (1.3) and it's db connection pool is configured by Spring. This application is but one of a list of applications in the same tomcat (a suite if you like) and many of them use an older version of commons-dbcp (1.2.1), all configured by Spring.

So, while I can compile (with Maven) my application with DBCP 1.3, I can't run it because Spring is trying to configure my db connection pool with the old version, which is in /shared/lib in Tomcat.

The problem I have is that I do not have time, nor the approval, to upgrade everything to 1.3, just the one application I'm fixing. Is it possible to for开发者_如何转开发ce Spring, in the components.xml file of my application (or by some other means) to the new DBCP version so that only it will run the new version and not affect any other application?


As long as you have the 1.2.1 version in /shared/lib there is no easy way to achieve what you need, as far as I know.

What you typically do in this case is that you bundle the 1.2.1 version with the applications that need that version (for example in WEB-INF/lib if they are web applications) and bundle the 1.3 version with your application.


You could possibly use Jar Jar to move dbcp 1.3 version classes under a different package and ask Spring to use them.

Yes, this is a hack.

0

精彩评论

暂无评论...
验证码 换一张
取 消