Java Maven抛出编译错误,“;找不到符号“;在@XmlAccessorType上,但我可以找到它

Java Maven抛出编译错误,“;找不到符号“;在@XmlAccessorType上,但我可以找到它,java,maven,jaxb,cannot-find-symbol,Java,Maven,Jaxb,Cannot Find Symbol,为什么我的mvn clean install命令告诉我它找不到Symbol,而它抱怨的类显然是可用的 我正在构建一个库来处理对RESTAPI(HP ALM)的调用。它返回xml,因此我必须解析结果 这个库已经完成了很多工作,但现在我想在一个更大的gui应用程序中测试它,所以我需要构建.jar并将其安装到本地maven存储库中。在图书馆的开发过程中没有(相关)错误 这是我在运行mvn clean install [INFO] Scanning for projects... [INFO] [INF

为什么我的mvn clean install命令告诉我它找不到Symbol,而它抱怨的类显然是可用的

我正在构建一个库来处理对RESTAPI(HP ALM)的调用。它返回xml,因此我必须解析结果

这个库已经完成了很多工作,但现在我想在一个更大的gui应用程序中测试它,所以我需要构建.jar并将其安装到本地maven存储库中。在图书馆的开发过程中没有(相关)错误

这是我在运行
mvn clean install

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building rest-qc 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ rest-qc ---
[INFO] Deleting C:\Data\workspaces\MRPB\workspace\rest-qc\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rest-qc ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ rest-qc ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 27 source files to C:\Data\workspaces\MRPB\workspace\rest-qc\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] \Data\workspaces\MRPB\workspace\rest-qc\src\main\java\infrastructure\Entity.java:[172,2] error: cannot find symbol
[ERROR] \Data\workspaces\MRPB\workspace\rest-qc\src\main\java\infrastructure\Entity.java:[173,2] error: cannot find symbol
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.400 s
[INFO] Finished at: 2016-08-26T10:32:32+02:00
[INFO] Final Memory: 10M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project rest-qc: Compilation failure: Compilati
on failure:
[ERROR] \Data\workspaces\MRPB\workspace\rest-qc\src\main\java\infrastructure\Entity.java:[172,2] error: cannot find symbol
[ERROR] \Data\workspaces\MRPB\workspace\rest-qc\src\main\java\infrastructure\Entity.java:[173,2] error: cannot find symbol
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
现在,我已经读到编译器插件2.3.2可能有一个bug,所以我尝试了该插件的多个其他版本。以下是3.1的答复:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building rest-qc 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ rest-qc ---
[INFO] Deleting C:\Data\workspaces\MRPB\workspace\rest-qc\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rest-qc ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ rest-qc ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 27 source files to C:\Data\workspaces\MRPB\workspace\rest-qc\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Data/workspaces/MRPB/workspace/rest-qc/src/main/java/infrastructure/Entity.java:[172,10] cannot find symbol
  symbol:   class XmlAccessorType
  location: class infrastructure.Entity
[ERROR] /C:/Data/workspaces/MRPB/workspace/rest-qc/src/main/java/infrastructure/Entity.java:[173,10] cannot find symbol
  symbol:   class XmlType
  location: class infrastructure.Entity
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.668 s
[INFO] Finished at: 2016-08-26T10:32:14+02:00
[INFO] Final Memory: 13M/163M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project rest-qc: Compilation failure: Compilation
 failure:
[ERROR] /C:/Data/workspaces/MRPB/workspace/rest-qc/src/main/java/infrastructure/Entity.java:[172,10] cannot find symbol
[ERROR] symbol:   class XmlAccessorType
[ERROR] location: class infrastructure.Entity
[ERROR] /C:/Data/workspaces/MRPB/workspace/rest-qc/src/main/java/infrastructure/Entity.java:[173,10] cannot find symbol
[ERROR] symbol:   class XmlType
[ERROR] location: class infrastructure.Entity
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
它们都给出了几乎相同的错误。3.1与2.3.2具有相同的行号,但字符索引在2->10之间变化。此外,3.1明确指出了导致错误的类。
实体
-类是一个标准生成的类,用于解释REST调用的结果。所有结果对象都将采用实体格式

作为参考,这里是我的pom.xml。我已经手动检查了jaxb绑定依赖项jar,以检查relevand注释类是否在库中。的确如此

<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>sdc.qualitycenter</groupId>
    <artifactId>rest-qc</artifactId>
    <version>1.0</version>
    <dependencies>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-bundle</artifactId>
            <version>1.19.1</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.9.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

4.0.0
质量中心
休息质控
1
泽西岛
球衣束
1.19.1
javax.xml.bind
jaxb api
2.1
朱尼特
朱尼特
3.8.1
测试
com.google.code.gson
格森
2.2.4
乔达时间
乔达时间
2.9.4
org.apache.commons
commons-lang3
3.4
org.apache.maven.plugins
maven编译器插件
2.3.2
1.7
1.7
最后但并非最不重要的是实体类(我已经手动添加了一个toString方法)

包基础设施;
/*
该文件由JavaTM XML绑定体系结构(JAXB)生成
参考实现,vhudson-jaxb-ri-2.1-456
看见http://www.oracle.com/technetwork/articles/javase/index-140168.html
重新编译源架构时,对此文件的任何修改都将丢失。
这个自动生成类的示例就是一个如何
通过xjc从XSD生成类以匹配jaxb标准。
XSD是一种用于描述类结构的格式
(注意:该类不是该类的实例)。
从XSD可以生成一个类java源文件。
编译此源文件时,可以“封送”实际的对象实例
从描述对象的XML(这次我们讨论的是一个实例,
不是一门课)。
这个过程有很多优点,并且是一种不受限制的序列化形式
语言依赖。
这是建议您使用实体的方法,尽管我们建议您使用
使用更简单的访问器自定义实体类。
*/
导入infrastructure.Entity.Fields.Field;
导入javax.xml.bind.annotation.*;
导入java.util.ArrayList;
导入java.util.List;
/**
*匿名复杂类型的Java类。
*
*以下架构片段指定此类中包含的预期内容。
*
* 
*   
*     
*       
*         
*           
*             
*               
*                 
*                   
*                     
*                       
*                         
*                           
*                             
*                           
*                           
*                         
*                       
*                     
*                   
*                 
*               
*             
*           
*         
*       
*       
*     
*   
* 
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name=”“,proporter={“字段”})
@XmlRootElement(name=“Entity”)
公共类实体{
@XmlElement(name=“Fields”,必需=true)
受保护的实体。字段;
@XmlAttribute(name=“Type”,required=true)
保护字符串类型;
公共实体(实体){
type=entity.getType();
fields=新的Entity.fields(Entity.getFields());
}
公共实体(){}
/**
*获取fields属性的值。
*
*@return可能的对象是{@link Entity.Fields}
*
*/
public Entity.Fields getFields(){
返回字段;
}
/**
*设置“字段”属性的值。
*
*@param值
*允许的对象是{@link Entity.Fields}
*
*/
公共无效设置字段(Entity.Fields值){
this.fields=值;
}
/**
*获取类型属性的值。
*
*@return可能的对象是{@link String}
*
*/
公共字符串getType(){
返回类型;
}
/**
*设置类型属性的值。
*
*@param值
*允许的对象是{@link String}
*
*/
公共void集合类型(字符串值){
this.type=值;
}
/**
*匿名复杂类型的Java类。
*
*以下架构片段指定此类中包含的预期内容。
*
* 
*   
*     
*       
*         
*           
*             
*               
*                 
*                   
*                 
*                 
*               
*             
*           
*         
*       
*     
*   
* 
*
*
*/
@XmlAccessorType(XmlAcce)
package infrastructure;

/*

This file was generated by the JavaTM Architecture for XML Binding(JAXB)
Reference Implementation, vhudson-jaxb-ri-2.1-456
See http://www.oracle.com/technetwork/articles/javase/index-140168.html
Any modifications to this file will be lost upon recompilation of the source schema.


This example of an automatically generated class is an example of how one can
generate classes from XSDs via xjc to match jaxb standards.
XSD is a format for describing a class structure
(note: the CLASS not an INSTANCE of the class).
From an XSD one can generate a class java source file.
When compiling this source file, one can "marshal" an actual object instance
from the XML describing the object (this time we are talking about an instance,
not a class).

this process has many advantages, and is a form of serialization that is not
language dependent.
This is the recommended way of working with entities, though we do suggest you
customize your entity class with simpler accessors.


 */

import infrastructure.Entity.Fields.Field;

import javax.xml.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * Java class for anonymous complex type.
 *
 * The following schema fragment specifies the expected content contained within this class.
 *
 * <complexType>
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="Fields">
 *           <complexType>
 *             <complexContent>
 *               <restriction base=
 *                  "{http://www.w3.org/2001/XMLSchema}anyType">
 *                 <sequence>
 *                   <element name="Field" maxOccurs="unbounded">
 *                     <complexType>
 *                       <complexContent>
 *                         <restriction base=
 *                            "{http://www.w3.org/2001/XMLSchema}anyType">
 *                           <sequence>
 *                             <element name="Value"
 *                               type="{http://www.w3.org/2001/XMLSchema}string"
 *                               maxOccurs="unbounded"/>
 *                           </sequence>
 *                           <attribute name="Name" use="required"
 *                             type="{http://www.w3.org/2001/XMLSchema}string" />
 *                         </restriction>
 *                       </complexContent>
 *                     </complexType>
 *                   </element>
 *                 </sequence>
 *               </restriction>
 *             </complexContent>
 *           </complexType>
 *         </element>
 *       </sequence>
 *       <attribute name="Type" use="required"
 *           type="{http://www.w3.org/2001/XMLSchema}string" />
 *     </restriction>
 *   </complexContent>
 * </complexType>
 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "fields" })
@XmlRootElement(name = "Entity")
public class Entity {

    @XmlElement(name = "Fields", required = true)
    protected Entity.Fields fields;
    @XmlAttribute(name = "Type", required = true)
    protected String type;


    public Entity(Entity entity) {
        type = entity.getType();
        fields = new Entity.Fields(entity.getFields());
    }

    public Entity() {}

    /**
     * Gets the value of the fields property.
     *
     * @return possible object is {@link Entity.Fields }
     *
     */
    public Entity.Fields getFields() {
        return fields;
    }

    /**
     * Sets the value of the fields property.
     *
     * @param value
     *            allowed object is {@link Entity.Fields }
     *
     */
    public void setFields(Entity.Fields value) {
        this.fields = value;
    }

    /**
     * Gets the value of the type property.
     *
     * @return possible object is {@link String }
     *
     */
    public String getType() {
        return type;
    }

    /**
     * Sets the value of the type property.
     *
     * @param value
     *            allowed object is {@link String }
     *
     */
    public void setType(String value) {
        this.type = value;
    }

    /**
     * Java class for anonymous complex type.
     *
     * The following schema fragment specifies the expected content contained within this class.
     *
     * <complexType>
     *   <complexContent>
     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       <sequence>
     *         <element name="Field" maxOccurs="unbounded">
     *           <complexType>
     *             <complexContent>
     *               <restriction base=
     *                  "{http://www.w3.org/2001/XMLSchema}anyType">
     *                 <sequence>
     *                   <element name="Value"
     *                     type="{http://www.w3.org/2001/XMLSchema}string"
     *                       maxOccurs="unbounded"/>
     *                 </sequence>
     *                 <attribute name="Name" use="required"
     *                   type="{http://www.w3.org/2001/XMLSchema}string" />
     *               </restriction>
     *             </complexContent>
     *           </complexType>
     *         </element>
     *       </sequence>
     *     </restriction>
     *   </complexContent>
     * </complexType>
     *
     *
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = { "field" })
    public static class Fields {

        @XmlElement(name = "Field", required = true)
        protected List<Field> field;


        public Fields(Fields fields) {
            field = new ArrayList<Field>(fields.getField());
        }


        public Fields() {}

        /**
         * Gets the value of the field property.
         *

         * This accessor method returns a reference to the live list, not a snapshot.
         * Therefore any  modification you make to the returned list will be present
         * inside the JAXB object.
         * This is why there is no set method for the field property.
         *
         * For example, to add a new item, do as follows:
         *
         *  getField().add(newItem); 
         *
         * Objects of the following type(s) are allowed in the list {@link Entity.Fields.Field }
         *
         *
         */
        public List<Field> getField() {
            if (field == null) {
                field = new ArrayList<Field>();
            }
            return this.field;
        }

        /**
         * Java class for anonymous complex type.
         *
         * The following schema fragment specifies the expected content contained
         * within this class.
         *
         * <complexType>
         *   <complexContent>
         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
         *       <sequence>
         *         <element name="Value"
         *            type="{http://www.w3.org/2001/XMLSchema}string"
         *            maxOccurs="unbounded"/>
         *       </sequence>
         *       <attribute name="Name" use="required"
         *          type="{http://www.w3.org/2001/XMLSchema}string" />
         *     </restriction>
         *   </complexContent>
         * </complexType>
         *
         */
        @XmlAccessorType(XmlAccessType.FIELD)
        @XmlType(name = "", propOrder = { "value" })
        public static class Field {

            @XmlElement(name = "Value", required = true)
            protected List<String> value;
            @XmlAttribute(name = "Name", required = true)
            protected String name;

            /**
             * Gets the value of the value property.
             *
             * This accessor method returns a reference to the live list, not a snapshot.
             * Therefore, any modification you make to the returned list will be present
             * inside the JAXB object. This is why there is no set method
             * for the value property.
             *
             * For example, to add a new item, do as follows:
             *
             * getValue().add(newItem);
             *

             * Objects of the following type(s) are allowed in the list {@link String }
             *
             *
             */
            public List<String> getValue() {
                if (value == null) {
                    value = new ArrayList<String>();
                }
                return this.value;
            }

            /**
             * Gets the value of the name property.
             *
             * @return possible object is {@link String }
             *
             */
            public String getName() {
                return name;
            }

            /**
             * Sets the value of the name property.
             *
             * @param value
             *            allowed object is {@link String }
             *
             */
            public void setName(String value) {
                this.name = value;
            }

        }

    }

    public String toString(){
        StringBuilder sb = new StringBuilder();
        sb.append("############## NEW ENTITY ################\n");
        List<Field> fields = this.getFields().getField();
        for (Field field : fields) {
            sb.append(field.getName() + " : " + field.getValue()+"\n");
        }
        return sb.toString();
    }
}