Autowire in class mentioned in bootstrap

时间:2016-10-20 18:46:55

标签: spring spring-mvc spring-boot spring-cloud-config

When the application starts EncryptionBootstrapConfiguration is not able to Autowire my custom TextEncryptor - https://github.com/spring-cloud/spring-cloud-commons/blob/cde7c7f3118382490c28776f66e0a56f248141fd/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfiguration.java

How can I ensure that this class Autowires my implementation of TextEncryptor.

Also, META-INF/spring.factories this class is mentioned as boostrap, how can i override that behavior?

My Spring-Boot Config Server -

@SpringBootApplication
@EnableConfigServer
public class App 
{


    public static void main( String[] args )
    {

        SpringApplication.run(App.class, args);
    }

}

and application.yml

server:
  port: 8760
  ssl:
    key-store: //path
    key-store-password: '{cipher}abc'
    key-store-type: jks
    key-password: '{cipher}abc'

As soon it finds {cipher} it fails with FailFastTextEncryptor.

1 个答案:

答案 0 :(得分:0)

为了让TextEncrytor自动装配它

  • 必须实施TextEncryptor interface
  • 必须在配置中明确地作为bean使用,或者使用注释(例如Component