ODL中如何将配置文件打包到运行目录下
来源:互联网 发布:手机淘宝号怎么注册 编辑:程序博客网 时间:2024/06/03 15:22
目录结构
config
|----src
| |----main
| |----java
| |----resource
| | |----initial
| | | |----config-example.xml
| | |----org.opendaylight.blueprint
| | |----config-blueprint.xml
| | ----yang
| |----example-config.yang
|----pom.xml
feature
|----src
|----main
|----features
|----feature.xml
[[pom.xml]]
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-parent</artifactId>
<version>0.6.0-Carbon</version>
<relativePath/>
</parent>
<groupId>org.exampleproj</groupId>
<artifactId>config</artifactId>
<version>1.0.0</version>
<name>ODL :: org.exampleproj :: ${project.artifactId}</name>
<packaging>bundle</packaging>
<dependencies>
...
</dependencies>
<!--build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
org.exampleproj.config.*,
org.opendaylight.yang.gen.v1.urn.exampleproj.config.example.config.rev171202.*
</Export-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<goals>
<goal>attach-artifact</goal>
</goals>
<phase>package</phase>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/classes/initial/example-config.xml</file>
<type>xml</type>
<classifier>config</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build-->
</project>
[[example-config.yang]]
module example-config {
yang-version 1;
namespace "urn:exampleproj:config:example-config";
prefix "example-config";
revision "2017-12-02" {
description "example config test";
}
container example-config {
leaf name {
type string;
}
leaf location {
type string;
}
}
}
[[config-example.xml]]
<example-config xmlns="urn:exampleproj:config:example-config">
<name>helloworld</name>
<location>overseas</location>
</example-config>
[[config-blueprint.xml]]
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
<odl:clustered-app-config id="exampleConfig"
default-config-file-name="example-config.xml"
binding-class="org.opendaylight.yang.gen.v1.urn.exampleproj.config.example.config.rev171202.ExampleConfig">
</odl:clustered-app-config>
</blueprint>
[[feature.xml]]
...
<feature name='odl-exampleproj-config' version='${project.version}' description='OpenDaylight :: exampleproj :: exampleconfig'>
<configfile finalname="etc/opendaylight/datastore/initial/config/example-config.xml">mvn:org.exampleproj/config/{{VERSION}}/xml/config</configfile>
<bundle>mvn:org.exampleproj/config/{{VERSION}}</bundle>
</feature>
...
如果不想把配置数据嵌入到config-blueprint.xml的<![CDATA[ 和 ]]>,那么就把配置文件写到example-config.xml中
当程序编译之后,在karaf/target/assembly/etc下没有产生opendaylight目录
当程序运行的时候会生成这个目录karaf/target/assembly/etc/opendaylight/datastore/initial/config, 并且把example-config.xml拷贝到这个目录下
当在pom.xml中加入了controller的config-parent之后,pom.xml中的build部分注释了,example-config.xml在运行的时候是出现在想要的目录中的,所以这段注释的并没有什么影响。绿色的部分可能跟build中定义的绿色部分有关吧,存疑。
如果只是修改配置文件,如何更新配置文件测试呢?
如果配置文件在<![CDATA[ 和 ]]>里面,只要替换karaf/target/assembly/system/org/exampleproj/config/1.0.0/config-1.0.0.jar包,重启karaf即可
如果配置文件已经在一个单独的文件中,并且声明了最终的文件位置是etc/opendaylight/datastore/initial/config/example-config.xml
那么需要修改karaf/target/assembly/system/org/exampleproj/config/1.0.0/config-1.0.0-config.xml,或者说覆盖此文件,
然后删掉karaf/target/assembly/etc下的opendaylight目录,如果不删掉,就不会更新,如果删掉,会把karaf/target/assembly/system/org/exampleproj/config/1.0.0/config-1.0.0-config.xml文件拷贝到etc相应的目录重命名成我们想要的文件。
参考文档
https://wiki.opendaylight.org/view/Using_Blueprint#Using_the_Datastore
http://blog.csdn.net/sonycong/article/details/49863915
- ODL中如何将配置文件打包到运行目录下
- maven将项目打包到tomcat目录下
- 如何将Metro 程序需要的文件加入到app运行目录(AppX文件夹中)
- 【maven】如何把配置文件打包到jar中
- 如何将 Memo中的文本内容保存到当前目录下的 Word 文档中
- Maven项目中如何将自定义标签的tld文件添加到META-INF目录下
- 如何利用启动脚本将目录下的多个jar自动加入到classpath中
- 在Windows下的Eclipse中如何将WordCount程序提交到集群运行
- [Java SE]如何将图片打包到jar中
- Java如何将图片打包到jar中
- [Java SE]如何将图片打包到jar中
- android 如何将数据库打包到apk中发布
- 如何将MP3文件打包到android APK中?
- 如何将黑莓程序配置文件导出到INI中
- Windows下如何将服务器目录映射到本地驱动器
- 如何将应用安装到system目录下
- 如何将初始化文件复制到可操作的目录下
- 如何将项目发布到tomcat的ROOT目录下
- AutoBanner
- springcloud(七):配置中心svn示例和refresh
- java通用工具类 ---获取目录文件大小
- 操作系统-动态内存分配算法
- [LeetCode] 66. Plus One ❤
- ODL中如何将配置文件打包到运行目录下
- 文件说明
- html 知识汇总与补充
- android权限大全
- 求矩阵的逆
- C语言哈夫曼树的实现---小勇勇
- 位运算的精髓
- 详解web标准
- CAMS