我創造耳朵的項目,我有2個模塊命名爲: mavenproject4的Web mavevnproject4的EJB如何從Web應用中的ejb模塊導入java文件?
我試圖導入從EJB模塊的一些接口和實體網絡module.But我不能。 我試圖通過pom.xml將ejb模塊作爲依賴添加到web模塊中。然後我的問題得到修復。是正確的嗎?
加入依賴後,我試圖運行的項目,我得到這個異常:
嚴重:異常而準備的應用程序:無法解析對應的持久化上下文REF名[mysessionbeans持久性單元.StudentDAOImpl/entityManager]在該模塊的範圍內調用[mavenproject4-ear#mavenproject4-ejb-1.0.jar]。請驗證您的申請。
我的堅持XML是 「的src/main /資源」 中關於項目結構EJB module.Detail信息圖像:
我的web應用程序的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>
<artifactId>mavenproject4</artifactId>
<groupId>az.lsim</groupId>
<version>1.0</version>
</parent>
<groupId>az.lsim</groupId>
<artifactId>mavenproject4-web</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>mavenproject4-web</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>az.lsim</groupId>
<artifactId>mavenproject4-ear</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
謝謝
不應該mavenproject4耳依賴是EJB JAR呢? – EdH
我相信你在你的POM文件中有一個錯字:而不是* mavenproject4-ear *作爲依賴項,你應該有* mavenproject4-ejb *。 – aribeiro