我是EAR應用程序開發新手。我想用下面的結構來構建應用程序:EAR項目轉換爲maven - web模塊停止工作
- EAR作爲包裝下面
- WEB模塊
- EJB模塊
(我使用Red Hat的JBoss Developer Studio中的IDE和野驢作爲服務器)
創建上述結構後,我測試了它 - 一切都被罰款。
我想爲整個解決方案添加maven支持,所以根據我使用的嚮導找到的文章:右鍵單擊項目「配置」 - >「轉換爲maven項目」。我先做了ejb和web模塊,然後再做耳朵。我還修改了ear pom.xml文件和application.xml文件。
轉換完成後,我的Web模塊停止工作。試圖查看歡迎頁面將返回錯誤404
下面你可以找到EAR pom.xml文件:
<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>sri3</groupId>
<artifactId>sri3</artifactId>
<version>1.0.0</version>
<packaging>ear</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10</version>
<configuration>
<earSourceDirectory>EarContent</earSourceDirectory>
<version>7</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<webModule>
<groupId>sri3.web</groupId>
<artifactId>sri3.web</artifactId>
</webModule>
<ejbModule>
<groupId>sri3.ejb</groupId>
<artifactId>sri3.ejb</artifactId>
</ejbModule>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>sri3.web</groupId>
<artifactId>sri3.web</artifactId>
<version>1.0.0</version>
<type>war</type>
</dependency>
<dependency>
<groupId>sri3.ejb</groupId>
<artifactId>sri3.ejb</artifactId>
<version>1.0.0</version>
<type>ejb</type>
</dependency>
</dependencies>
</project>
下面你可以找到EAR application.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" id="Application_ID" version="7">
<display-name>sri3</display-name>
<module>
<web>
<web-uri>sri3.web.war</web-uri>
<context-root>sri3.web</context-root>
</web>
</module>
<module>
<ejb>sri3.ejb.jar</ejb>
</module>
<library-directory>lib</library-directory>
</application>
我發現了幾個文章和問題與廣泛描述適當的EAR配置,但沒有一個幫助我。我忽略了什麼?
感謝所有提前。
好的。所以如果我很好理解,我應該把所有的項目包括在內,包括一個在父項目中的項目?它應該是什麼樣的項目? – Piotr
這是一個PAM項目 –
這個項目只包含子項目,如果你看看NetBeans的示例項目,你完全理解結構 –