我在做的是一个游戏项目:暂时有两个工程,一个是gameCommon 放一些每个工程都会运用到的常量和服务器配置文件,没有引用到任何的jar包。 第二个是游戏主项目,引用了各种开猿jar包。我该如何编写pom文件才能使工程正常打出jar呢?
这是common的pom:<parent>报错啊,说什么Missing artifact 缺父类导入的jar包
<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> <artifactId>GameCommon</artifactId> <parent> <groupId>com.oasgames.dota</groupId> <artifactId>GameServer</artifactId> <version>0.0.1-SNAPSHOT</version> <relativePath>../GameServer</relativePath> </parent> </project>
这是主模块的pom
<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>
<groupId>com.oasgames.dota</groupId>
<artifactId>GameServer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>utf8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<modules>
<module>../GameCommon</module>
</modules>
<!-- 依赖的jar -->
<dependencies>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.10</version>
</dependency>
<dependency>
<groupId>com.oasgames.dota</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/GameCommon-0.0.1-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oasgames.dota</groupId>
<artifactId>ibatis</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ibatis-2.3.4.726.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oasgames.dota</groupId>
<artifactId>dom4j</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/dom4j.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oasgames.dota</groupId>
<artifactId>pool</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/commons-pool-1.6.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oasgames.dota</groupId>
<artifactId>proxool</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/proxool-0.9.1.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oasgames.dota</groupId>
<artifactId>dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ibatis-dao-2.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>2.0.4</version>
<type>bundle</type>
</dependency>
</dependencies>
</project>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
嗯,你这个确实有点儿乱。梳理了下,你分common和 GameServer
其实不用模块,你可以对common单独编译后执行mnvcleaninstall后就可以在 GameServer中加个dependency就搞定了。
回复 @bBugyang:如果你放在resource下肯定可以打包进去。恩,我工程里面的,excel文件和xml文件可以加载进来吗?我有一次运行的时候报错xls文件找不到打包的指令是mvnpackage吧?如果你非要使用模块,common和GameServer应该是两个模块,再在这两个模块上层目录加个pom.xml做为parent用来描述模块。在 GameServer中也可以引用 common模块。
<systemPath>不是必须,因为你指定了依赖会自动从中央库下载jar,你这样指定反而失去了Maven的优势。
关于模块的部分参考http://juvenshun.iteye.com/blog/305865