我正在尝试部署spring-boot 2.0.4应用程序。配置如下所示:
@Component
@Configuration
@PropertySource("classpath:elast.properties")
public class ElastSearchLogLevel {
private static final Logger LOG = LoggerFactory.getLogger(ElastSearchLogLevel.class);
@Value("${elast.mail.to}")
private String to;
...
在Windows本地运行正常,但在Linux框中显示:
WARN o.a.commons.logging.impl.Jdk14Logger.log - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'elastSearchBootApplication': Unsatisfied dependency expressed through field 'logsSearch'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elastSearchLogLevel': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'elast.mail.to' in value "${elast.mail.to}"
实例“ elastSearchLogLevel”已自动连接到SpringBootApplication
类中。理想情况下,我想提供一个可以从中读取属性的外部配置文件。正如在其中一个论坛中所建议的那样,我也曾尝试过,但是没有用。
@PropertySource("classpath:file:///my/file/path/elast.properties")
确定更多代码:
@ComponentScan(basePackages = "some.packer.log")
@SpringBootApplication
@EnableScheduling
public class ElastSearchBootApplication {
...