0

我正在尝试用几个无状态会话 bean 创建一个简单的项目。我花了一个多星期的时间来发现问题。尝试了各种依赖,但没有任何效果。可能有人可以帮助我解决这个问题。但是当我用 maven 编译它时,我得到以下错误:

无法在项目测试中执行目标 org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile):编译失败:编译失败:[ERROR] \workspace\test\src\main\ java\com\test\services\Test1ServiceImpl.java:[14,1] 找不到符号 [ERROR] 符号:类 Stateless [ERROR] @Stateless [ERROR] \workspace\test\src\main\java\com\test\ services\Test1ServiceImpl.java:[16,1] 找不到符号 [ERROR] 符号:远程类 我的 POM 看起来像这样:http://maven.apache.org/maven-v4_0_0.xsd">4.0.0

<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<name>test-common</name>
<packaging>ejb</packaging>

<repositories>
    <repository>
        <id>repository.jboss.org-public</id>
        <name>JBoss.org Maven repository</name>
        <url>https://repository.jboss.org/nexus/content/groups/public</url>
    </repository>
</repositories>
<dependencies>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.4</version>
    </dependency>

    <dependency>
        <groupId>org.jboss.ejb3</groupId>
        <artifactId>jboss-ejb3-ext-api</artifactId>
        <version>1.1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>jboss</groupId>
        <artifactId>jboss-annotations-ejb3</artifactId>
        <version>4.2.3.GA</version>
        <scope>provided</scope>
    </dependency>
    <dependency>

        <groupId> com.thoughtworks.xstream</groupId>
        <artifactId>xstream</artifactId>
        <version>1.2.2</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax.jms</groupId>
        <artifactId>jms</artifactId>
        <version>1.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging-api</artifactId>
        <version>1.1</version>
        <scope>provided</scope>
    </dependency>


</dependencies>
<build>
    <plugins>
        <plugin>
            <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-surefire-plugin</artifactId>
            <version>2.4.3</version>
            <configuration>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-ejb-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <ejbVersion>3.0</ejbVersion>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

4

2 回答 2

0

“无国籍阶级”?没有包裹?您的 JAva 源代码是否正确(带有导入?)

于 2012-05-20T03:47:49.067 回答
0

您必须包含包含 javax.ejb.* API 的 jar。

将依赖项添加到 pom.xml 中的以下 jar。

对于 Java EE 6:http: //download.java.net/maven/2/javax/javaee-api/6.0/javaee-api-6.0.jar

于 2012-05-21T09:49:33.113 回答