c3p0-config.xml放在src目录下,程序以app运行没有错误 但是以web server运行,就会解析不到配置?

那我们要如何解决呢?

查看官网知道:web server程序对c3p0-config.xml的放置位置是有要求的!

By default, c3p0 will look for an XML configuration file in its classloader’s resource path under the name “/c3p0-config.xml”. That means the XML file should be placed in a directly or jar file directly named in your applications CLASSPATH, in WEB-INF/classes, or some similar location. If you prefer not to bundle your configuration with your code, you can specify an ordinary filesystem location for c3p0’s configuration file via the system property com.mchange.v2.c3p0.cfg.xml.

意思是配置文件必须放在classpath路径中,在web环境下就是classes,这个目录中也就是src中的java文件编译过来的。

根据官网所提供的信息,成功的利用c3p0链接到了数据库! IDEA的web程序下的c3p0配置文件应该放在哪?

相关文章: