Skip to content

wjw465150/vertx-config-ext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vertx-config-ext

load vertx config file from classpath!

依赖引入

通过Maven的pom.xml引入。

  ......

	<dependencies>
		<dependency>
			<groupId>io.vertx</groupId>
			<artifactId>vertx-core</artifactId>
      <version>4.2.5</version>
		</dependency>

		<dependency>
			<groupId>io.vertx</groupId>
			<artifactId>vertx-config</artifactId>
      <version>4.2.5</version>
		</dependency>

    <dependency>
      <groupId>com.github.wjw465150</groupId>
      <artifactId>vertx-config-ext</artifactId>
      <version>4.2.5</version>
    </dependency>
	</dependencies>

  ......

或者通过Gradle的build.gradle引入

dependencies {
  implementation "io.vertx:vertx-core:4.2.5"
  implementation "io.vertx:vertx-config:4.2.5"
  implementation "com.github.wjw465150:vertx-config-ext:4.2.5"
}

使用示例

  ConfigStoreOptions classpathStore = new ConfigStoreOptions()
      .setType("classpath")  //<1>
      .setConfig(new JsonObject().put("path", "conf/conf-test.json")); //<2>
    

  ConfigRetrieverOptions configOptions = new ConfigRetrieverOptions().addStore(classpathStore);
  ConfigRetriever retriever = ConfigRetriever.create(vertx,configOptions);

<1> setType的值必须是classpath

<2> key的值必须是path,value值是配置文件在classpath里的绝对路径,注意千万不要以/开头!