Spring + Tomcat:加载了错误的驱动程序类,如何调试?

时间:2014-07-08 17:10:06

标签: java mysql spring tomcat

我有一个datasource bean,看起来像

@Override
    public DataSource dataSource() {
        final BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName(getDriverClassName());
        dataSource.setUrl(getUrl());
        dataSource.setUsername(getUser());
        if (!getPassword().trim().isEmpty()) {
            dataSource.setPassword(getPassword());
        }

        LOGGER.debug("DriverClass={}, URL={}, User={}", getDriverClassName(), getUrl(), getUser());
        return dataSource;
    }

当我在日志中看到时,我将日志视为

09:09:28.874 [localhost-startStop-1] DEBUG c.y.c.p.profiles.MySqlDatabaseConfig - DriverClass=java.database.jdbc.mysql.MyWrapper, URL=jdbc:mysql://host:3306/pryme, User=app_user

MyWrapper类是加密类以获取安全密钥。但我在日志中看到错误

org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'app_user'@'62.117.121.130' (using password: YES))  

最后,我看到行为

09:09:31,367 ERROR [WebappClassLoader] The web application [/common] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

但我从未注册过此课程[com.mysql.jdbc.Driver]

更多背景
属性来自bean,具有以下规则

@PropertySources({
        @PropertySource("classpath:properties/default.properties"),
        @PropertySource(value = "file:/home/y/conf/app/app.properties", ignoreResourceNotFound = true)
})
public class MySqlDatabaseConfig extends JpaCommonConfig {

default.properties看起来像

database_driverClassName=com.mysql.jdbc.Driver
database_url=jdbc:mysql://localhost:3306/pryme?createDatabaseIfNotExist=true
database_username=root
database_password=

但在服务器上,我的/home/y/conf/app/app.properties有行

database_driverClassName: java.database.jdbc.mysql.MyWrapper

我现在不去做什么

0 个答案:

没有答案