2011-08-12 53 views
1

我正尝试使用在GlassFish的应用程序客户端容器中运行的应用程序客户端创建基于maven的企业应用程序。它应该适合作为Netbeans“企业应用程序”+“企业应用程序客户端”的项目模板,但使用maven而不是ant。在Java EE中使用Maven创建“应用程序客户端”

到现在为止我有以下项目

  • 大会Maven项目
  • EAR-模块
  • EJB-模块
  • WEB模块(亦可与耳内)
  • Swing Client模块

大会pom.xml的样子:

<project xml... 
     <modules> 
     <module>shop-ear</module> 
     <module>shop-web</module> 
     <module>shop-ejb</module> 
     <module>shop-client</module> 
     </modules> 
    </project> 

耳的pom.xml包含

<project ...> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
    <artifactId>shop</artifactId> 
    <groupId>my.package.name</groupId> 
    <version>1.0-SNAPSHOT</version> 
    </parent> 
    <groupId>ch.hslu.edu.enapp</groupId> 
    <artifactId>shop-ear</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>ear</packaging> 
    <!-- ... --> 
    <dependencies> 
    <dependency> 
     <groupId>my.package.name</groupId> 
     <artifactId>shop-ejb</artifactId> 
     <version>1.0-SNAPSHOT</version> 
     <type>ejb</type> 
    </dependency> 
    <dependency> 
     <groupId>my.package.name</groupId> 
     <artifactId>shop-web</artifactId> 
     <version>1.0-SNAPSHOT</version> 
     <type>war</type> 
    </dependency> 
    <dependency> 
     <groupId>my.package.name</groupId> 
     <artifactId>shop-client</artifactId> 
     <version>1.0-SNAPSHOT</version> 
     <type>jar</type> 
    </dependency> 
</dependencies> 

而且Swing客户端的pom.xml包含

<project xmlns=....> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
     <artifactId>shop</artifactId> 
     <groupId>my.package.name</groupId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 

    <groupId>my.package.name</groupId> 
    <artifactId>shop-client</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 
    <name>shop-client</name> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-jar-plugin</artifactId> 
       <version>2.3.1</version> 
       <configuration> 
        <archive> 
         <manifest> 
          <mainClass>my.package.name.Main</mainClass> 
         </manifest> 
        </archive> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
    <repositories> 
     <repository> 
      <url>http://download.java.net/maven/2/</url> 
      <id>java.net</id> 
      <layout>default</layout> 
      <name>java.net</name> 
     </repository> 
    </repositories> 
    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.1</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.jdesktop</groupId> 
      <artifactId>beansbinding</artifactId> 
      <version>1.2.1</version> 
      <type>jar</type> 
      <scope>compile</scope> 
     </dependency> 
    </dependencies> 
</project> 

目前我有没有依赖关系Swing客户端和EJB模块之间。我只想得到一个简单的Swing表单,然后用完了ACC表单GlassFish(v 3.1.1)。

但这不起作用。 Swing客户端打包到ear-file里的lib文件夹中,我无法启动它。

您是否知道完成此任务的教程或示例?

回答

2

你的耳朵POM需要配置耳插件一样(也许你只是离开了它,当你把它放到你的问题?):

<plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-ear-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <version>6</version> 
       <generateApplicationXml>true</generateApplicationXml> 
       <defaultLibBundleDir>lib</defaultLibBundleDir> 
       <modules> 
        <webModule> 
         <groupId>com.foo</groupId> 
         <artifactId>shop-web</artifactId> 
         <contextRoot>webstuff</contextRoot> 
        </webModule> 
        <ejbModule> 
         <groupId>com.foo</groupId> 
         <artifactId>shop-ejb</artifactId> 
         <classifier>single</classifier> 
         <bundleFileName>shop-ejb.jar</bundleFileName> 
        </ejbModule> 
        <jarModule> 
         <groupId>com.foo</groupId> 
         <artifactId>shop-client</artifactId> 
         <bundleDir>/</bundleDir> 
         <bundleFileName>shop-client.jar</bundleFileName> 
         <includeInApplicationXml>true</includeInApplicationXml> <!-- i don't remember if this was absolutely necessary --> 
        </jarModule> 
       </modules> 
      </configuration> 
     </plugin> 

这将外面打包应用程序客户端jar lib文件夹,并且将帮助你为你的war模块定义上下文根(没有其他方法可以找到)。 bundleFileName对于让URL启动客户端变得更有意义非常重要。

我不知道该放在一起单一的教程,但有些资源是:

相关问题