Comments (5)
找到原因了,DisconfAspectJ
只会在enable.remote.conf=true
的时候才会进行切面。
配置Bean加上@DisconfFile
后已经变为一个proxy bean,这样读取的配置就不能被正确注入,所以都是null。
难道annotation的bean不能使用本地配置?不解。
from disconf.
验证发现,把所有的静态的,动态托管的配置文件放在本地classpath,设置enable.remote.conf=true
。
conf_server_host
设置为一个错误的地址,这样才能都正确使用本地的配置运行。
@knightliao 能否解释下这个问题。
因为有很多配置项,开发人员每个人都有自己的环境,配置项会不同。我希望所有的配置文件都放在本地classpath中,作为Local开发配置,可以个人修改。其他环境使用disconf远程配置。
from disconf.
hi 功能上应该是没有问题的。
- 因为配置bean实例的field亦会被注入值,即便配置Bean加上@DisconfFile后已经变为一个proxy bean,也可以正确找到对应的bean并注入
- 你可以跑下 https://github.com/knightliao/disconf-demos-java/tree/master/disconf-standalone-demo 这个demo试试?把配置下下来,然后本地跑试试。
- 有问题可以再联系我
from disconf.
@knightliao 感谢反馈。
annotation的使用本地文件配置功能确实有问题。我使用了 https://github.com/knightliao/disconf-demos-java/tree/master/disconf-standalone-demo 进行了测试。
拉取了 https://github.com/knightliao/disconf-demos-java/tree/master/disconf-standalone-demo/conffiles 所有的文件到classpath。
运行日志如下:
2016-01-14 10:04:58,972 [main] INFO com.example.disconf.demo.task.DisconfDemoTask - baobao--baifa: 5200.0
2016-01-14 10:04:58,972 [main] INFO com.example.disconf.demo.task.DisconfDemoTask - baobao--yuerbao: 5200.0
2016-01-14 10:05:03,978 [main] INFO com.example.disconf.demo.task.DisconfDemoTask - redis( 127.0.0.1 , 6379 ) get key : disconf_key
2016-01-14 10:05:03,978 [main] INFO com.example.disconf.demo.task.DisconfDemoTask - redis( 127.0.0.1 , 6379 )
2016-01-14 10:05:03,990 [main] INFO com.example.disconf.demo.task.DisconfDemoTask - code config:
2016-01-14 10:05:03,990 [main] INFO com.example.disconf.demo.task.DisconfDemoTask - autoservice: bbd
2016-01-14 10:05:03,990 [main] INFO com.example.disconf.demo.task.DisconfDemoTask - autoservice2: cc
2016-01-14 10:05:03,990 [main] INFO com.example.disconf.demo.task.DisconfDemoTask - static file data: 147
2016-01-14 10:05:03,990 [main] INFO com.example.disconf.demo.task.DisconfDemoTask - static item data: 56
可以看到code.properties中的属性是空。与我在自己的project中测试跟踪到的问题一致。
from disconf.
hi,
- 从日志中你也可以看到,除了 code.properties有问题外,其它的配置都是正确的(他们也是采用annotation), 所以 整体上是没有问题的,code.properties 是个例,下面我们来看下code.properties
- codeConfig的代码是
@service
@DisconfFile(filename = "code.properties", copy2TargetDirPath = "disconf")
public class CodeConfig {
private String codeError = "";
@DisconfFileItem(name = "syserror.paramtype", associateField = "codeError")
public String getCodeError() {
return codeError;
}
public void setCodeError(String codeError) {
this.codeError = codeError;
}
}
路径是 copy2TargetDirPath = "disconf" 你把 code.properties放到 disconf目录下(resouce/disconf)下,就OK了
from disconf.
Related Issues (20)
- 指定-Ddisconf.conf_server_host=地址无效? HOT 2
- disconf.properties文件属性配置空格问题
- 更新数据库成功,但Zookeeper更新失败,请重试或联系管理员。 HOT 1
- 请问能管理php程序的配置文件吗 HOT 2
- 动态配置更新时序问题
- disconf 会导致服务异常么?
- 现在支持springboot 的yml托管到disconf了吗,系统启动配置无法加载
- DisconfCenterFile在加载classpath下的disconf.properties路径不正确
- 项目启动后实例为0 HOT 1
- 请问和zookeeper有什么不一样的地方吗?
- disconf-web maven打包问题
- Inconsistent library versions notice.
- 登录提示用户不存在
- 文件流未关闭会不会有问题
- how to run in kubernetes
- when can run in kubernetes
- 调用雪花算法时,不间断的报连接KeeperErrorCode = ConnectionLoss for
- disconfig是怎么解析@Value注解的,请给出核心解析类
- SpringBoot集成disconf首次启动配置未及时加载问题解决
- Code optimization suggestions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from disconf.