apolloconfig / apollo-use-cases

Show various usage scenarios and sample codes of the Apollo configuration center, welcome to share more configuration use cases in your daily work!
Apache License 2.0
945 stars 401 forks source link

jasypt-spring-boot 2.1.0 会使placeholder方式的自动刷新功能失效 #16

Closed techzealot closed 5 years ago

techzealot commented 5 years ago

引入jasypt-spring-boot-starter后,apollo本身的placeholder方式的自动刷新功能失效(包括未加密的key),refreshscope方式的不受影响可以正常刷新,请问有什么解决方法吗?谢谢! 具体表现为:

  1. 配置更新后AutoUpdateConfigChangeListener并未收到事件通知(控制台无日志打印)
  2. 采用ApolloConfigChangeListener注解可以监听到事件
  3. config.getProperty方式可以获取最新的值
  4. 配置中心的实例列表会认为该应用已经使用了最新配置,实际并未生效
nobodyiam commented 5 years ago

我本地跑了一下,没有这个问题啊,spring-boot-encrypt稍加改造,然后让它持续输出input和input1

@SpringBootApplication
@EnableApolloConfig
public class Application implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Value("${test.input}")
    private String input;

    @Value("${test.input1}")
    private String input1;

    @Override
    public void run(String... args) throws Exception {
      new Thread(() -> {
        while (true) {
          System.err.println("test.input 值 ENC(Ore69lUopDHL5R8Bw/G3bQ==) 解密后:" + input);
          System.err.println("test.input1 不需要解密:" + input1);
          try {
            TimeUnit.SECONDS.sleep(1);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        }
      }).run();
    }
}

在Apollo中修改完test.input1=ckl33就立马刷新了,http://106.12.25.204:8070/config.html?#/appid=spring-boot-encrypt

image

techzealot commented 5 years ago

@nobodyiam 您好,找到问题了,原因是jasypt-spring-boot-starter的版本升级导致的,描述的情形发生在 jasypt-spring-boot-starter的2.1.0版本,版本为1.16时,刷新是正常的,应该是2.1.0的改动会影响Apollo的功能,能不能请大佬研究下具体的原因,最好能兼容下,或者显示声明下2.1.0不兼容自动更新,花了好几天部署调试,都有点怀疑人生了,下次再也不敢乱调版本了,谢谢回复。

nobodyiam commented 5 years ago

后续研究一下~

techzealot commented 5 years ago

今天又测试了下jasypt-spring-boot-starter 1.16,发现不加密的字段可以动态刷新,加密的字段无法刷新,刷新加密字段时AutoUpdateConfigChangeListener没有触发

milosun1995 commented 4 months ago

后续研究一下~ jasypt-spring-boot-starter版本与apollo冲突问题导致不能实时刷新成功,后面有解决方案吗? 谢谢