question
The following warning appears when starting the Eureka registration center
WARN 3732 — [main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
INFO 3732 — [main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
Literal translation first hand:
no URLs are polled as dynamic configuration sources.
To enable URLs as dynamic configuration sources, define the system property archaius.configurationSource.additionalUrls or make config.properties available on the classpath.
analyze
The source code prompt is also very considerate, and the solution is given immediately after the warning.
Enter the prompt class URLConfigurationSource
/**
* Create the instance for the default list of URLs, which is composed by the following order
*
* <ul>
* <li>A configuration file (default name to be <code>config.properties</code>, see {@link #DEFAULT_CONFIG_FILE_NAME}) on the classpath
* <li>A list of URLs defined by system property {@value #CONFIG_URL} with values separated by comma <code>","</code>.
* </ul>
*/
public URLConfigurationSource() {
List<URL> urlList = new ArrayList<URL>();
URL configFromClasspath = getConfigFileFromClasspath();
if (configFromClasspath != null) {
urlList.add(configFromClasspath);
}
String[] fileNames = getDefaultFileSources();
if (fileNames.length != 0) {
urlList.addAll(Arrays.asList(createUrls(fileNames)));
}
if (urlList.size() == 0) {
configUrls = new URL[0];
logger.warn("No URLs will be polled as dynamic configuration sources.");
logger.info("To enable URLs as dynamic configuration sources, define System property "
+ CONFIG_URL + " or make " + DEFAULT_CONFIG_FILE_FROM_CLASSPATH + " available on classpath.");
} else {
configUrls = urlList.toArray(new URL[urlList.size()]);
logger.info("URLs to be used as dynamic configuration source: " + urlList);
}
}
Apparently Eurak depends on the netflix-archaius package, which produces a warning.
What is Archaius
Archaius contains a set of configuration management APIs used by Netflix. It provides the following functions:
Dynamic Typed Properties
High-throughput and thread-safe configuration operations
A polling framework that allows fetching property changes for configuration sources
A callback mechanism that is invoked when the valid/"winning" property mutates (in an ordered hierarchy of configurations)
A JMX MBean that can be accessed via JConsole to inspect and invoke operations on properties
Out-of-the-box combined configuration (with an ordered hierarchy), suitable for applications (and most web applications that prefer to use a convention-based properties file location)
Implementation of dynamic configuration sources for URL, JDBC, and Amazon DynamoDB
Scala dynamic property wrapper
solve
It can be solved by meeting the requirements required for loading, and you can remove dependencies if you don’t need them
Option One
Create a config.properties file in the resources directory.
Option II
Start parameter specification
-Darchaius.configurationSource.additionalUrls=file:\E:\conf.properties
method three
Startup class specification
public class Application {
static {
System.setProperty("archaius.configurationSource.defaultFileName", "test.properties");
}
public static void main(String[] args) {
SpringApplication.run(Application.class,args);
}
}
Loading success message:
INFO 2672 — [ main] cncsources.URLConfigurationSource : URLs to be used as dynamic configuration source: [file:/G:/xxx/target/classes/test.properties, file:/E:/conf.properties ]
Official website reference:
https://docs.spring.io/spring-cloud-netflix/docs/2.2.10.RELEASE/reference/html/#external-configuration-archaius
The belt is getting wider and I don't regret it, and I am haggard because of Yixiao.