Feiyizhan commented on issue #9891:
URL: https://github.com/apache/dubbo/issues/9891#issuecomment-1899629725
修改启动方法,设置应用启动时修改缓存目录增加应用名子目录。
```java
public static void main(String[] args) {
// 创建SpringApplication实例
SpringApplication application = new
SpringApplication(Application.class);
// 添加自定义的ApplicationContextInitializer
application.addInitializers(context -> {
// 获取Environment对象
Environment env = context.getEnvironment();
// 从Environment中读取"spring.application.name"属性值
String appName = env.getProperty("spring.application.name");
String filePath = System.getProperty("user.home") +
File.separator + ".dubbo" +File.separator + appName;
// 修改dubbo的本地缓存路径,避免缓存冲突
System.setProperty("dubbo.meta.cache.filePath", filePath);
System.setProperty("dubbo.mapping.cache.filePath",filePath);
});
//启动应用
application.run(args);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]