autowired报错
来源:3-2 dao的迁移上
慕设计2030095
2019-11-19 10:58:53

package com.om.o2ov2.config.dao;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.om.o2ov2.util.DESUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.beans.PropertyVetoException;
@Configuration
@MapperScan("com.om.o2ov2.dao")
public class DataSourceConfiguration {
@Value("${myjdbc.driver}")
private String jdbcDriver;
@Value("${myjdbc.url}")
private String jdbcUrl;
@Value("${myjdbc.username}")
private String jdbcUsername;
@Value("${myjdbc.password}")
private String jdbcPassword;
/**
* 生成spring-dao.xml对应的bean dataSource
* @return
*/
@Bean(name = "dataSource")
public ComboPooledDataSource createDataSource() throws PropertyVetoException {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setDriverClass(jdbcDriver);
dataSource.setJdbcUrl(jdbcUrl);
dataSource.setUser(DESUtil.getDecryptString(jdbcUsername));
dataSource.setPassword(DESUtil.getDecryptString(jdbcPassword));
dataSource.setMaxPoolSize(30);
dataSource.setMinPoolSize(10);
dataSource.setAutoCommitOnClose(false);
dataSource.setCheckoutTimeout(10000);
dataSource.setAcquireRetryAttempts(2);
return dataSource;
}
}配置了路由
1回答
同学你好,这个应该是检测级别比较高,造成的报错,并不影响程序的编译与执行。这里建议同学使用@Resource替代@Autowire试试。
如果我的回答解决了你的疑惑,请采纳。祝:学习愉快~
相似问题