我为POJO课程创建游泳池时遇到了麻烦。 这是我的代码片段:
@Bean
public CommonsPool2TargetSource poolTargetSource() {
CommonsPool2TargetSource commonsPool2TargetSource = new CommonsPool2TargetSource();
commonsPool2TargetSource.setMinIdle(5);
commonsPool2TargetSource.setMaxSize(50);
commonsPool2TargetSource.setTargetClass(JioTUURL.class);
return commonsPool2TargetSource;
}
@Bean
public ProxyFactoryBean proxyFactoryBean() {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTargetSource(poolTargetSource());//The type org.apache.commons.pool2.PooledObjectFactory cannot be resolved. It is indirectly referenced from required .class files
return proxyFactoryBean;
}
@Bean
public MethodInvokingFactoryBean poolConfigAdvisor() {
MethodInvokingFactoryBean poolConfigAdvisor = new MethodInvokingFactoryBean();
poolConfigAdvisor.setTargetObject(commonsPoolTargetSource());
poolConfigAdvisor.setTargetMethod("getMaxIdle");
return poolConfigAdvisor;
}
我在编译时收到错误消息,如评论中所述。
早些时候我使用的是CommonsPoolTargetSource,但得出的结论是它已被弃用。
我正在使用的罐子/版本: Spring 4.3.1, aopalliance-1.0.jar, 共享记录-1.2.jar, commons-pool的-1.6.jar, 核心IO-1.3.1.jar, rxjava-1.1.6.jar, SLF4J-API 1.7.21.jar, SLF4J-简单1.7.21.jar