文档章节

OSGI 模块化 POM设计

l
 lvk618
发布于 2016/06/15 09:13
字数 1150
阅读 11
收藏 0

为了模块化开发的规范性,下面列出了一般的模块化分块,以后可以以此进行模块化构建项目。


一、父亲POM

<?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/maven-v4_0_0.xsd">
    <!--Base -->
    <modelVersion>4.0.0</modelVersion>
    <groupId>jmust.common</groupId>
    <artifactId>utility</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>
    <name>module</name>
    <url>http://common.jmust.com/utility</url>
    <distributionManagement>
        <repository>
            <id>jmust</id>
            <name>jmust Repository</name>
            <url>http://0.0.0.0:8080/nexus/content/repositories/jmustRepos/</url>
            <layout>default</layout>
        </repository>
    </distributionManagement>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.3</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <!-- 依赖关系管理 -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
                <type>jar</type>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.osgi</groupId>
                <artifactId>org.osgi.compendium</artifactId>
                <version>4.2.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <!-- 依赖 -->
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <type>jar</type>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <!--子模块 -->
    <modules>
        <module>contract</module>
        <module>service</module>
        <module>gateway</module>
    </modules> 

</project>

二、契约POM

<?xml version='1.0' encoding='UTF-8' ?>
<project xmlns:pom="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>jmust.common</groupId>
        <artifactId>utility</artifactId>
        <version>1.0.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <description>

    </description>
    <groupId>jmust.common.utility</groupId>
    <artifactId>contract</artifactId>
    <packaging>jar</packaging>
    <version>1.0.0</version>
    <name>服务V1.0.0</name>
    <url>http://jmust.common.com/utility/contract/</url>
    <distributionManagement>
        <repository>
            <id>jmust</id>
            <name>jmust Repository</name>
            <url>http://0.0.0.0:8081/nexus/content/repositories/jmustRepos/</url>
            <layout>default</layout>
        </repository>
    </distributionManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <phase>deploy</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.3</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.7.2</version>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                        <manifestEntries>
                            <Class-Path>.</Class-Path>
                            <Built-By>youjie</Built-By>
                            <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
                            <Bundle-Name>${project.groupId}.${project.ArtifactId}</Bundle-Name>
                            <Bundle-SymbolicName>${project.groupId}.${project.ArtifactId}</Bundle-SymbolicName>
                            <Bundle-Version>${project.version}</Bundle-Version>
                            <Bundle-Vendor>${project.groupId}</Bundle-Vendor>
                            <Export-Package>jmust.common.utility.contract;version="1.0.0"</Export-Package>
                            <Import-Package>
                                org.osgi.framework,org.slf4j
                            </Import-Package>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi</artifactId>
            <version>3.0.0</version>
            <type>jar</type>
        </dependency>
    </dependencies>
</project>

三、实现POM

<?xml version='1.0' encoding='UTF-8' ?>
<project xmlns:pom="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>jmust.common</groupId>
        <artifactId>utility</artifactId>
        <version>1.0.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <description>

    </description>
    <groupId>jmust.common.utility</groupId>
    <artifactId>gateway</artifactId>
    <packaging>jar</packaging>
    <version>1.0.0</version>
    <name>实现V1.0.0</name>
    <url>http://jmust.common.com/utility/gateway/</url>
    <distributionManagement>
        <repository>
            <id>jmust</id>
            <name>jmust Repository</name>
            <url>http://0.0.0.0:8081/nexus/content/repositories/jmustRepos/</url>
            <layout>default</layout>
        </repository>
    </distributionManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <phase>deploy</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.3</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.7.2</version>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                        <manifestEntries>
                            <Class-Path>.</Class-Path>
                            <Built-By>youjie</Built-By>
                            <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
                            <Bundle-Name>${project.groupId}.${project.ArtifactId}</Bundle-Name>
                            <Bundle-SymbolicName>${project.groupId}.${project.ArtifactId}</Bundle-SymbolicName>
                            <Bundle-Version>${project.version}</Bundle-Version>
                            <Bundle-Vendor>${project.groupId}</Bundle-Vendor>
                            <Export-Package>jmust.common.utility.gateway;version="1.0.0"</Export-Package>
                            <Import-Package>
                                org.osgi.framework,org.slf4j,org.apache.camel,
                                jmust.common.utility.contract.response,
                                jmust.common.utility.entity,
                                javax.persistence,javax.persistence.criteria,
                                org.apache.commons.codec.digest
                            </Import-Package>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi</artifactId>
            <version>3.0.0</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>2.15.1</version>
        </dependency>     
        <dependency>
            <groupId>jmust.common.utility</groupId>
            <artifactId>contract</artifactId>
            <version>1.0.0</version>
            <type>jar</type>
        </dependency>
    </dependencies>
</project>

四、服务POM

<?xml version='1.0' encoding='UTF-8' ?>
<project xmlns:pom="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>jmust.common</groupId>
        <artifactId>utility</artifactId>
        <version>1.0.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <description>

    </description>
    <groupId>jmust.common.utility</groupId>
    <artifactId>service</artifactId>
    <packaging>jar</packaging>
    <version>1.0.0</version>
    <name>服务V1.0.0</name>
    <url>http://jmust.common.com/utility/service/</url>
    <distributionManagement>
        <repository>
            <id>jmust</id>
            <name>jmust Repository</name>
            <url>http://0.0.0.0:8081/nexus/content/repositories/jmustRepos/</url>
            <layout>default</layout>
        </repository>
    </distributionManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <phase>deploy</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.3</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.7.2</version>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                        <manifestEntries>
                            <Class-Path>.</Class-Path>
                            <Built-By>youjie</Built-By>
                            <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
                            <Bundle-Name>${project.groupId}.${project.ArtifactId}</Bundle-Name>
                            <Bundle-SymbolicName>${project.groupId}.${project.ArtifactId}</Bundle-SymbolicName>
                            <Bundle-Version>${project.version}</Bundle-Version>
                            <Bundle-Vendor>${project.groupId}</Bundle-Vendor>
                            <Export-Package>jmust.common.utility.service;version="1.0.0"</Export-Package>
                            <Import-Package>
                                org.osgi.framework,org.slf4j,org.apache.camel,
                                jmust.common.utility.contract.response,
                                jmust.common.utility.entity,
                                javax.persistence,javax.persistence.criteria,
                                org.apache.commons.codec.digest
                            </Import-Package>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi</artifactId>
            <version>3.0.0</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>2.15.1</version>
        </dependency>     
        <dependency>
            <groupId>jmust.common.utility</groupId>
            <artifactId>gateway</artifactId>
            <version>1.0.0</version>
            <type>jar</type>
        </dependency>
    </dependencies>
</project>

完毕!

本文转载自:http://blog.csdn.net/lk10207160511/article/details/50408011

l
粉丝 3
博文 80
码字总数 792
作品 0
广州
私信 提问
EclipseCon发布企业OSGi标准

加州EclipseCon上,OSGi联 盟宣布长期酝酿的OSGi企业标准(第四次发布,Version 4.2)审批通过。OSGi的本次发布针对广泛的Java应用服务开发人员群体,捆绑组件标准。更大的模块化和增长的组件...

小卒过河
2010/03/29
532
0
利用 R-OSGi 实现分布式 OSGi 应用

OSGi(Open Service Gateway Initiative)是业界中最知名的 Java 模块化技术规范,其核心设计思想是面向服务的组件模型(Service-Oriented Component Model)。OSGi 发展至今已经得到了众多企...

IBMdW
2012/06/27
1K
2
关于《OSGi实战》这本书

OSGi规范编写规整、内容翔实,若需了解OSGi技术细节,OSGi规范将是一个很好的选择。但在阅读该规范的过程中,你可能会发现它面向的是该规范的实现者而非使用者。本书的创作初衷就是打造一本面...

生气的散人
2012/12/11
3.1K
6
Hasor 同 Spring OSGi 的比较及设计思想

这篇是承接《轻量级 Java 开发框架 设计》系列Blog文的后续文章,本文将通过设计思想,实现方式上对比 Hasor Spring OSGi 三者。 在开启本文之前我想用最简短的一段话介绍一下 Hasor 。 Haso...

哈库纳
2013/12/27
4.3K
27
maven与osgi的结合

各位大大们.....小的最近遇到特烦恼一件事。学习osgi...目前的理解是热插拔,项目模块化。但是项目模块化我觉的用maven很爽啊。他们之间有什么关系吗?osgi我用的是spring提供的实现。服务器...

bluesky4cn
2013/01/04
5.5K
3

没有更多内容

加载失败,请刷新页面

加载更多

反编译9.png图片还原

本文链接:https://blog.csdn.net/a1140778530/article/details/10528507 经常反编译apk文件找资源,9.png的文件处理起来很麻烦。 最近使用Ant自动编译打包app时,从别处搜罗来的9.png文件导...

shzwork
30分钟前
6
0
Shell脚本应用 – for、while循环语句

一、for循环语句 在实际工作中,经常会遇到某项任务需要多次执行的情况,而每次执行时仅仅是处理的对象不一样,其他命令相同。例如:根据通讯录中的姓名列表创建系统账号等情况。 当面对各种...

linux-tao
30分钟前
5
0
RPA风潮下企业财务工作模式的变革

RPA(机器人流程自动化)在财务领域的应用,正给企业财务带来前所未有的改变。 前RPA时代,财务领域面临的痛点 在RPA机器人应用之前,企业财务工作进程的推进,主要通过财务人员人工操作或信...

UiBot
35分钟前
5
0
Hive之命令行修改表注释

最近遇到一个需求,在不重建表的情况下,修改表的注释,hive有没有类似关系型数据库的SQL命令来修改呢,找了下,亲测有效,如下List-1 List-1 hive>use your_schemahvie>ALTER TABLE tabl...

克虏伯
35分钟前
5
0
是什么,它的作用是什么

在HTML文档的首部往往会有这么一句话<!DOCTYPE html>,许多时候我们忽视了它的存在,它实际上是一个声明,告诉浏览器用哪种HTML版本的规范来解读HTML文档。 尽管我们不给出这句声明浏览器照样...

前端老手
41分钟前
4
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部