测试文件中出现错误“找不到符号”

时间:2018-08-19 14:42:56

标签: java-ee pom.xml

我已经尝试了一些基于复数形式的代码。这是课程链接:https://app.pluralsight.com/library/courses/java-ee-getting-started/table-of-contents

  

Blockquote       包com.pluralsight.javaee.bookstore.repository;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class BookRepositoryTest {
@Deployment
public static JavaArchive createDeployment() {
    return ShrinkWrap.create(JavaArchive.class)
            .addClass(BookRepository.class)
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}

@org.junit.Test
public void create() {
}

}

这是我的pom.xml文件

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
     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.pluralsight.javaee-getting-started.javaee-getting-started-m6</groupId>
<artifactId>bookstore-back</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>Getting Started :: javaee-getting-started-m6 :: Testing the Repository :: Back</name>

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <!-- Test -->
    <version.junit>4.12</version.junit>
    <version.arquillian>1.1.13.5</version.arquillian>
    <version.arquillian.wildfly>2.0.2.Final</version.arquillian.wildfly>
    <version.shrinkwrap>1.2.6</version.shrinkwrap>
    <!-- Plugins -->
    <version.surefire.plugin>2.19.1</version.surefire.plugin>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.arquillian</groupId>
            <artifactId>arquillian-universe</artifactId>
            <version>${version.arquillian}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>

    <!-- TEST -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${version.junit}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.arquillian.universe</groupId>
        <artifactId>arquillian-junit</artifactId>
        <scope>test</scope>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.jboss.shrinkwrap</groupId>
        <artifactId>shrinkwrap-api</artifactId>
        <version>${version.shrinkwrap}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.wildfly.arquillian</groupId>
        <artifactId>wildfly-arquillian-container-remote</artifactId>
        <version>${version.arquillian.wildfly}</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <finalName>bookstore-back</finalName>
    <defaultGoal>compile</defaultGoal>
    <plugins>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${version.surefire.plugin}</version>
            <configuration>
                <systemPropertyVariables>
                    <arquillian.launch>arquillian-wildfly-remote</arquillian.launch>
                </systemPropertyVariables>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</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>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>src</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
    </plugins>
</build>

当我尝试编译时,出现错误: [错误] /E:/IntellijWorkspace/BookstoreBack/src/main/java/com/pluralsight/javaee/bookstore/repository/BookRepositoryTest.java:[12,6]找不到符号 [错误]符号:类部署 [错误]位置:com.pluralsight.javaee.bookstore.repository.BookRepositoryTest类 [错误] /E:/IntellijWorkspace/BookstoreBack/src/main/java/com/pluralsight/javaee/bookstore/repository/BookRepositoryTest.java:[16,40]找不到符号 [错误]符号:变量EmptyAsset [错误]位置:com.pluralsight.javaee.bookstore.repository.BookRepositoryTest类 [错误] /E:/IntellijWorkspace/BookstoreBack/src/main/java/com/pluralsight/javaee/bookstore/repository/BookRepositoryTest.java:[14,34]找不到符号 [错误]符号:类JavaArchive [错误]位置:com.pluralsight.javaee.bookstore.repository.BookRepositoryTest类 请支持我修复这些错误。谢谢!

0 个答案:

没有答案