Exception thrown from ApplicationListener handling ContextClosedEvent
在获取配置文件中的值时,使用了如下代码:
@Autowired
private Environment env;
String host =env.getProperty("sftp.host");
String port = env.getProperty("sftp.port");
String name = env.getProperty("sftp.name");
String password = env.getProperty("sftp.password");
String basePath = env.getProperty("sftp.basePath");
String filePath = env.getProperty("sftp.filePath");
然后启动时就出现了下面的错误信息
020-06-03 11:30:27.087 [main] WARN [org.springframework.context.annotation.AnnotationConfigApplicationContext:997] - Exception thrown from ApplicationListener handling ContextClosedEvent
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'rabbitConnectionFactory': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
后来发现把获取值的代码放入方法中就不会报错了