Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
techzealot opened this issue Dec 25, 2018 · 5 comments

Comments

@techzealot
Copy link

techzealot commented Dec 25, 2018

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

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

nobodyiam commented Dec 25, 2018

我本地跑了一下,没有这个问题啊,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
Copy link
Author

techzealot commented Dec 25, 2018

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

@nobodyiam
Copy link
Member

后续研究一下~

@techzealot techzealot changed the title jasypt-spring-boot会使placeholder方式的自动刷新功能失效 jasypt-spring-boot 2.1.0 会使placeholder方式的自动刷新功能失效 Dec 25, 2018
@techzealot
Copy link
Author

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

@milosun1995
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants