- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
为什么我的 mvn clean install 命令告诉我它找不到符号,而它提示的类似乎显然可用?
我正在构建一个库来处理对 REST API (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 可能存在错误,因此我尝试了多个其他版本的插件。这是 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 具体说明了导致错误的类。 Entity
类是一个标准的生成类,用于解释 REST 调用的结果。所有结果对象都将采用实体格式。
作为引用,这是我的 pom.xml。我已经手动检查了 jaxb-bind 依赖项 jar 以检查相关注释类是否在库中。确实如此。
<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>
最后但同样重要的是,实体类(我手动添加了一个 toString 方法)
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();
}
}
最佳答案
我假设你定义为依赖的版本
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
</dependency>
太老了。所以我建议使用 newer version like
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.12</version>
</dependency>
关于java - Maven 在@XmlAccessorType 上抛出编译错误 "Cannot find symbol",但我可以找到它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39162192/
我试图理解 Maven 模块和 Maven 项目之间的区别。哪一个是什么以及我应该在哪里?谢谢 最佳答案 maven 模块就像一个 maven“子项目”。一个 Maven 项目包含 1 个或多个模块。
我们目前没有自己的存储库。因此,当我们使用 Maven 构建时,它会在当前用户的主目录中创建 .m2 存储库。 现在有两个在 Maven Central 中找不到的第三方 jar。假设其中之一是 ha
我有 Maven 项目,但在其中一台服务器上我必须在没有 Maven 的情况下构建它。 可以使用标准 JDK 命令。在哪里可以看到 Maven 在构建项目时向 JDK 发送了哪些命令? 最佳答案 Ma
我打算将 ImageJ 用于 web 应用程序,但似乎 ImageJ maven 依赖项不在中央 maven 存储库中。 我说得对吗? 当 ImageJ 2.x 发布时,这会改变吗? 最佳答案 您可以
我可以有多个 Maven 实例吗,即 Mave 2.2.1 和 Maven 3 都指向同一个本地存储库? 我的意思是我知道我可以在技术上将每个 settings.xml 指向同一个文件夹,但从长远来看
我有两个项目,项目 A 依赖于项目 B,所以通常,我的 projectA/pom.xml 中有以下部分: projectB blabla version1 我想要实现的目标非常简
在网上的许多地方,我看到它讨论了要使 maven 构建可重现,明确指定所有使用的插件的版本号很重要,这样更新的插件就不会破坏构建。推荐的方法似乎是使用 enforcer 插件。下面是我在网上找到的复制
有没有办法暂停 Maven 执行流程以提供命令提示符,以便用户可以输入文本。 然后我希望将提供的文本存储在 Maven 属性中。 如果用户输入可以被屏蔽,那将是一个奖励。 这对于避免在 pom.xml
我正在尝试使用 maven 插件将 maven java 项目的源文件夹添加到 Eclipse。 尝试使用 org.codehaus.mojo 插件时,我收到以下错误 无法在项目应用程序框架上执行目标
我有两个几乎相同的配置文件。我不想在每个配置文件中复制配置,而是希望一个配置文件从另一个配置文件“继承”,但我没有看到使用 maven 3 执行此操作的明显方法。 在 Maven 中是否可以继承配置文
我是 Maven 新手,花了大约 3 天的时间使用程序集插件生成 zip 文件,引用 http://www.petrikainulainen.net/programming/tips-and-tric
想象一下这种情况。我有一个使用 Maven 管理的开源项目,它依赖于一个不在 Maven 存储库中的知名库(例如 jpathwatch)。我怎样才能让它发挥作用? 直接的方法是将 jpathwatch
我将 Neo4j 和 MongoDB 与 Grails 一起使用,我想知道 Maven Neo4j 插件是否也为我的构建提供了 Neo4j 依赖项。 MongoDB 也是如此。 我很困惑。我应该使用什
我正在尝试同时发布多个 Maven 项目,将它们部署到 oss.sonatype.org,然后将它们发布到 Maven Central。 我有一个构建 pom,用于一起构建多个多模块项目。构建 pom
我有一个带有 maven pom.xml 的项目 4.0.0 Minimal-J Minimal-J 0.1-SNAPSHOT Minimal-J
我需要制作一个下载maven项目并打印其依赖项的小程序 像这样: MavenArtifactRepository repository = new MavenArtifactRepository("t
我有一个关于 maven 在构建过程中如何计算类路径的问题。具体来说,控制何时使用“目标/类”以及何时使用来自存储库(本地/远程)的“jar”。 我有一个版本为 1.0.0-SNAPSHOT 的项目,
我有一个 maven 项目,需要在命令行(-Dmy.property=val)设置一个属性。 我需要做的是将该字符串转换为所有大写,因为该属性是 用于通过 maven-resources-plugin
引用和转义如何对传递给 Maven 插件的参数起作用? 例如,我想将多个文件名作为参数传递给 Maven Exec 插件运行的应用程序: mvnDebug exec:java -Dexec.mainC
我在父 pom 的导入的 dependencyManagement 部分中指定了一个库版本。我确认我的有效 pom 只有一次出现这种依赖。它在依赖管理部分: org.jav
我是一名优秀的程序员,十分优秀!