Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

jgroups/autoconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

25 Commits

Repository files navigation

autoconfig

autoconfig使用一套配置模板,为不同的环境生成相应的具体配置。

利用Maven打包,运行命令:

mvn clean package

在target目录下生成一个jar包autoconfig-1.0-SNAPSHOT.jar,运行这个jar包,命令如下:

java -jar target/autoconfig-1.0-SNAPSHOT.jar

在配置文件的模板 config.properties.vm 中有一个配置变量 ${me_lbing_value} 在执行autoconfig的时候需要被替换,那怎么给这个配置项赋值呢?autoconfig提供了两种方式来给配置变量赋

第一从java属性文件中读取;
第二是交互式地编辑.

autoconfig首先读取当前工作目录的antx.properties文件,如果没有则读取${user.home}/antx.properties文件,如果这个文件也不存在,autoconfig就会启动交互式编辑器请求用户输入配置变量的值,如果配置变量的值是不完整的autoconfig则会立即停止配置并抛出一个异常。如果java属性文件的位置不在autoconfig默认的位置可以通过参数autoconfig.userProperties进行配置。处于简单起见,我们在当前目录新建一个java属性文件antx.properties,这个文件中定义了配置变量${me_lbing_value}的值。

##注: 1,autoconfig依赖于Maven.
2,有人或许会感觉迷惑,在模板文件config.properties.vm中,需要被替换的明明是me_lbing_value,为什么在auto-config.xml文件中会定义属性 me.lbing.value 呢?现在只需要记住属性名中的点在autoconfig执行的时候会被替换成下划线.
3,maven对应插件:

<plugin>
 <groupId>com.alibaba.citrus.tool</groupId>
 <artifactId>autoconfig-maven-plugin</artifactId>
 <version>${autoconfig-plugin-version}</version>
 <executions>
 <execution>
 <phase>package</phase>
 <goals>
 <goal>autoconfig</goal>
 </goals>
 </execution>
 </executions>
</plugin>

About

autoconfig使用一套配置模板,为不同的环境生成相应的具体配置。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /