Closed koywang closed 8 years ago
是不是没有配置
<!-- 使用托管方式的disconf配置(无代码侵入, 配置更改会自动reload)-->
<bean id="configproperties_disconf"
class="com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:/autoconfig.properties</value>
<value>classpath:/autoconfig2.properties</value>
</list>
</property>
</bean>
<bean id="propertyConfigurer"
class="com.baidu.disconf.client.addons.properties.ReloadingPropertyPlaceholderConfigurer">
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="propertiesArray">
<list>
<ref bean="configproperties_disconf"/>
</list>
</property>
</bean>
@knightliao 试过了,加了这2个配置也是一样!!
配置文件下载了,文件里的key也加载到了,不知道怎么回事spring的xml中取key就取不到!!!
你看下 报错信息是否在下载文件之前。另外下载文件内容你也瞅瞅看是否正确
09/01 14:01:28 [INFO] ZookeeperMgr initInternal(100) - zoo prefix: /disconf
09/01 14:01:28 [INFO] DisconfMgr firstScan(103) - ******************************* DISCONF END FIRST SCAN *******************************
09/01 14:01:28 [WARN] GenericTypeAwarePropertyDescriptor getWriteMethodForActualAccess(135) - Invalid JavaBean property 'locations' being accessed! Ambiguous write methods found next to actually used [public void com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean.setLocations(java.util.List)]: [public void org.springframework.core.io.support.PropertiesLoaderSupport.setLocations(org.springframework.core.io.Resource[])]
09/01 14:01:28 [WARN] DisconfCenterStore storeOneFile(73) - There are two same fileName key!!!! jdbc.properties
09/01 14:01:28 [WARN] DisconfCenterStore storeOneFile(73) - There are two same fileName key!!!! redis.properties
09/01 14:01:29 [WARN] DisconfCenterStore storeOneFile(73) - There are two same fileName key!!!! config.properties
09/01 14:01:29 [INFO] ReloadablePropertiesFactoryBean loadProperties(172) - Loading properties file from class path resource [jdbc.properties]
09/01 14:01:29 [INFO] ReloadablePropertiesFactoryBean loadProperties(172) - Loading properties file from class path resource [redis.properties]
09/01 14:01:29 [INFO] ReloadablePropertiesFactoryBean loadProperties(172) - Loading properties file from class path resource [config.properties]
这提示There are two same fileName key!!!
这是什么原因引起的??
09/01 14:18:41 [INFO] ContextLoader initWebApplicationContext(305) - Root WebApplicationContext: initialization started
09/01 14:18:41 [INFO] XmlWebApplicationContext prepareRefresh(578) - Refreshing Root WebApplicationContext: startup date [Thu Sep 01 14:18:41 CST 2016]; root of context hierarchy
09/01 14:18:41 [INFO] XmlBeanDefinitionReader loadBeanDefinitions(317) - Loading XML bean definitions from URL [file:/Users/koy/git/sms/target/classes/spring/root.xml]
09/01 14:18:42 [INFO] XmlBeanDefinitionReader loadBeanDefinitions(317) - Loading XML bean definitions from URL [file:/Users/koy/git/sms/target/classes/spring/spring-redis.xml]
09/01 14:18:42 [INFO] ConfigMgr init(28) - --------------- LOAD CONFIG START ---------------
09/01 14:18:42 [INFO] ConfigMgr init(31) - Finer print: koy-pro.local_0_1a643739-f6a0-47fd-a173-f44ac56b4ad1
09/01 14:18:42 [INFO] ClassLoaderUtil <clinit>(62) - classpath: /Users/koy/git/sms/target/classes/
09/01 14:18:42 [INFO] DisInnerConfigHelper verifyUserConfig(49) - SERVER disconf.conf_server_host: [disconf.test.com]
09/01 14:18:42 [INFO] DisInnerConfigHelper verifyUserConfig(59) - SERVER disconf.version: 1_0_0_1
09/01 14:18:42 [INFO] DisInnerConfigHelper verifyUserConfig(68) - SERVER disconf.app: sms
09/01 14:18:42 [INFO] DisInnerConfigHelper verifyUserConfig(77) - SERVER disconf.env: rd
09/01 14:18:42 [INFO] DisInnerConfigHelper verifyUserConfig(81) - SERVER disconf.enable.remote.conf: true
09/01 14:18:42 [INFO] DisInnerConfigHelper verifyUserConfig(85) - SERVER disconf.debug: false
09/01 14:18:42 [INFO] DisInnerConfigHelper verifyUserConfig(90) - SERVER disconf.user_define_download_dir: ./disconf/download
09/01 14:18:42 [INFO] DisInnerConfigHelper verifyUserConfig(106) - SERVER disconf.ignore: []
09/01 14:18:42 [INFO] ConfigMgr init(47) - --------------- LOAD CONFIG END ---------------
09/01 14:18:42 [INFO] DisconfMgr firstScan(85) - ******************************* DISCONF START FIRST SCAN *******************************
09/01 14:18:42 [INFO] Reflections scan(224) - Reflections took 78 ms to scan 1 urls, producing 3 keys and 11 values
09/01 14:18:42 [INFO] ScanStaticStrategy analysis4DisconfFile(157) - disconf file hasn't any items: com.koy.disconf.config.Config
09/01 14:18:42 [INFO] ScanStaticStrategy analysis4DisconfFile(157) - disconf file hasn't any items: com.koy.disconf.config.JDBCConf
09/01 14:18:42 [INFO] ScanStaticStrategy analysis4DisconfFile(157) - disconf file hasn't any items: com.koy.disconf.config.RedisConfig
09/01 14:18:43 [INFO] HttpClientUtil execute(81) - execute http request [null], status code [200]
09/01 14:18:43 [INFO] HttpClientUtil execute(81) - execute http request [null], status code [200]
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:zookeeper.version=3.3.6-1366786, built on 07/29/2012 06:22 GMT
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:host.name=192.168.9.81
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:java.version=1.8.0_91
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:java.vendor=Oracle Corporation
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:java.class.path=/Users/koy/apache-maven-3.3.9/boot/plexus-classworlds-2.5.2.jar
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:java.library.path=/Users/koy/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:java.io.tmpdir=/var/folders/8w/pwdj448936nbcvj49f6nrxpc0000gn/T/
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:java.compiler=<NA>
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:os.name=Mac OS X
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:os.arch=x86_64
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:os.version=10.11.6
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:user.name=koy
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:user.home=/Users/koy
09/01 14:18:43 [INFO] ZooKeeper logEnv(97) - Client environment:user.dir=/Users/koy/git/sms
09/01 14:18:43 [INFO] ZooKeeper <init>(379) - Initiating client connection, connectString=192.168.9.125:2181 sessionTimeout=10000 watcher=com.baidu.disconf.core.common.zookeeper.inner.ResilientActiveKeyValueStore@570ff5ed
09/01 14:18:43 [INFO] ClientCnxn startConnect(1058) - Opening socket connection to server /192.168.9.125:2181
09/01 14:18:43 [INFO] ClientCnxn primeConnection(947) - Socket connection established to koys2/192.168.9.125:2181, initiating session
09/01 14:18:43 [INFO] ClientCnxn readConnectResult(736) - Session establishment complete on server koys2/192.168.9.125:2181, sessionid = 0x156e3c693290018, negotiated timeout = 10000
09/01 14:18:43 [INFO] ConnectionWatcher process(73) - zk SyncConnected
09/01 14:18:43 [INFO] ConnectionWatcher connect(63) - zookeeper: 192.168.9.125:2181 , connected.
09/01 14:18:43 [INFO] ZookeeperMgr initInternal(100) - zoo prefix: /disconf
09/01 14:18:43 [INFO] DisconfMgr firstScan(103) - ******************************* DISCONF END FIRST SCAN *******************************
09/01 14:18:44 [WARN] GenericTypeAwarePropertyDescriptor getWriteMethodForActualAccess(135) - Invalid JavaBean property 'locations' being accessed! Ambiguous write methods found next to actually used [public void com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean.setLocations(java.util.List)]: [public void org.springframework.core.io.support.PropertiesLoaderSupport.setLocations(org.springframework.core.io.Resource[])]
09/01 14:18:44 [WARN] DisconfCenterStore storeOneFile(73) - There are two same fileName key!!!! redis.properties
09/01 14:18:44 [WARN] DisconfCenterStore storeOneFile(73) - There are two same fileName key!!!! jdbc.properties
09/01 14:18:44 [WARN] DisconfCenterStore storeOneFile(73) - There are two same fileName key!!!! config.properties
09/01 14:18:44 [INFO] ReloadablePropertiesFactoryBean loadProperties(172) - Loading properties file from class path resource [redis.properties]
09/01 14:18:44 [INFO] ReloadablePropertiesFactoryBean loadProperties(172) - Loading properties file from class path resource [jdbc.properties]
09/01 14:18:44 [INFO] ReloadablePropertiesFactoryBean loadProperties(172) - Loading properties file from class path resource [config.properties]
09/01 14:18:44 [INFO] AutowiredAnnotationBeanPostProcessor <init>(153) - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
09/01 14:18:44 [ERROR] DruidDataSource init(629) - dataSource init error
java.sql.SQLException: ${jdbc.driverClassName}
at com.alibaba.druid.util.JdbcUtils.createDriver(JdbcUtils.java:510)
at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:563)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
.....
现在就一直是这样的异常信息,怎么改都不行,之前其他项目用2.6.33有跑通过,但是这个项目2.6.33和2.6.35都不行,不知道是不是pom中依赖有冲突???
jdbc.properties 贴出来看看 ?
There are two same fileName key! 这个问题是因为你可能同时用了注解式和XML配置式。
jdbc.properties
## MySqlConfig
#jdbc.driverClassName=com.mysql.jdbc.Driver
##jdbc.url=jdbc:mysql://192.168.8.123:3306/smsManagement?useUnicode=true&characterEncoding=utf8
jdbc.url=jdbc:mysql://10.1.20.11:3306/sms?useUnicode=true&characterEncoding=utf8
jdbc.username=😌
jdbc.password=XXXX```
redis.properties
redis.host=192.168.9.124:6379,192.168.9.124:6380
redis.maxTotal=600
redis.maxIdle = 20
redis.maxWaitMillis = 5000
redis.testOnBorrow = true
redis.testWhileIdle = false
redis.testOnReturn = false
情况是这样的,我这个项目依赖的第三方库比较多;
另外一个项目比较简单,配置上去马上就成功了,我猜可能是maven依赖的包冲突引起的
jdbc.driverClassName 不是被你注释掉了?
另外,你把密码删除掉,隐私处理一下
搞定了!!
下面是spring配置