日食:can';找不到javax.xml.datatype.XMLGregorianCalendar-Java11
我已经将一个项目从Java1.8迁移到Java11。在这个过程中,我不得不安装一个更新版本的eclipse来使用Java11JDK日食:can';找不到javax.xml.datatype.XMLGregorianCalendar-Java11,java,eclipse,maven,java-11,Java,Eclipse,Maven,Java 11,我已经将一个项目从Java1.8迁移到Java11。在这个过程中,我不得不安装一个更新版本的eclipse来使用Java11JDK Eclipse IDE for Enterprise Java Developers. Version: 2018-12 (4.10.0) Build id: 20181214-0600 该应用程序是一个maven项目,可以从命令行成功编译,但是eclipse抱怨它无法解析javax.xml.datatype.xmlgoriancalendar 我使用右键单击pr
Eclipse IDE for Enterprise Java Developers.
Version: 2018-12 (4.10.0)
Build id: 20181214-0600
该应用程序是一个maven项目,可以从命令行成功编译,但是eclipse抱怨它无法解析javax.xml.datatype.xmlgoriancalendar
我使用右键单击projectmaven->updateproject从eclipse更新了maven项目
我可以从项目maven依赖项中看出,包含了jaxp-api-1.4.2.jar,并且存在javax.xml.datatype.xmlgoriiancalendar类
我如何解决Eclipse抱怨类javax.xml.datatype.xmlgoriancalendar无法解决的问题
使用未解析的javax.xml.datatype.XMLGregorianCalendar初始化:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2018.08.17 at 01:14:19 PM BST
//
package com.qlsdistribution.fps.production.contentagent;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="From" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* <element name="To" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"from",
"to"
})
@XmlRootElement(name = "JobAPI_GetArchivedJobs")
public class JobAPIGetArchivedJobs {
@XmlElement(name = "From")
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar from;
@XmlElement(name = "To")
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar to;
/**
* Gets the value of the from property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getFrom() {
return from;
}
/**
* Sets the value of the from property.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setFrom(XMLGregorianCalendar value) {
this.from = value;
}
/**
* Gets the value of the to property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getTo() {
return to;
}
/**
* Sets the value of the to property.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setTo(XMLGregorianCalendar value) {
this.to = value;
}
}
//
//该文件由JavaTM XML绑定体系结构(JAXB)参考实现v2.2.11生成
//看
//重新编译源架构时,对此文件的任何修改都将丢失。
//生成日期:2018.08.17英国夏令时下午1:14:19
//
包com.qlsdistribution.fps.production.contentagent;
导入javax.xml.bind.annotation.XmlAccessType;
导入javax.xml.bind.annotation.XmlAccessorType;
导入javax.xml.bind.annotation.xmlement;
导入javax.xml.bind.annotation.XmlRootElement;
导入javax.xml.bind.annotation.XmlSchemaType;
导入javax.xml.bind.annotation.XmlType;
导入javax.xml.datatype.XMLGregorianCalendar;
/**
*匿名复杂类型的Java类。
*
*以下架构片段指定此类中包含的预期内容。
*
*
*复合型
*复合物含量
*限制基数=”{http://www.w3.org/2001/XMLSchema}“任何类型”
*序列
*元素名称=“来自”类型=”{http://www.w3.org/2001/XMLSchema}dateTime“minOccurs=“0”/
*元素名称=“To”类型=”{http://www.w3.org/2001/XMLSchema}dateTime“minOccurs=“0”/
*/顺序
*/限制
*/complexContent
*/complexType
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name=),比例={
“从”,
“到”
})
@XmlRootElement(name=“JobAPI\u GetArchivedJobs”)
公共类JobAPIGetArchivedJobs{
@xmlement(name=“From”)
@XmlSchemaType(name=“dateTime”)
保护XmlGregorianalendar不受影响;
@xmlement(name=“To”)
@XmlSchemaType(name=“dateTime”)
受保护的XMLGregorianCalendar到;
/**
*获取from属性的值。
*
*@返回
*可能的对象是
*{@link XmlGregorianalendar}
*
*/
公共XMLGregorianCalendar getFrom(){
返乡;
}
/**
*设置from属性的值。
*
*@param值
*允许的对象是
*{@link XmlGregorianalendar}
*
*/
public void setFrom(XMLGregorianCalendar值){
this.from=值;
}
/**
*获取to属性的值。
*
*@返回
*可能的对象是
*{@link XmlGregorianalendar}
*
*/
公共XMLGregorianCalendar getTo(){
返回;
}
/**
*设置“到”属性的值。
*
*@param值
*允许的对象是
*{@link XmlGregorianalendar}
*
*/
公共无效设置为(XMLGregorianCalendar值){
这个。to=值;
}
}
pom.xml的精简版本:
4.0.0
com.qlsdistribution.fps
确保新安装的Java JDK 11位于窗口>首选项:Java>已安装的JRE(或在macOS Eclipse>首选项:Java>已安装的JRE上)
确保在项目中JavaSE-11
用作执行环境:
在您的pom.xml
中,将
1.11
替换为以下两行:
11
11
右键单击项目并选择Maven>更新项目…
如果使用(=默认包包含文件module info.java
),请确保module info.java
包含行requires java.xml代码>
→ 在Package Explorer或Project Explorer中,显示子节点JRE系统库[JavaSE-11]
,我遇到了同样的问题,我刚刚通过选择项目并按下鼠标第二个按钮,使maven->update Project解决了这个问题。我希望它能有所帮助您的类型可能存在重复的依赖项javax.xml.datatype.xmlgoriancalendar
请尝试此处发布的答案->请显示您的
pom.xml
和相关的代码片段。@mle代码从命令行成功生成并运行,因此问题不在于代码或pom,而在于eclipse。我将更新这个问题,以包括代码和pom.xml的相关部分。我已经读到,这可能与旧的java版本有关,包括jdk中的jax,并与jaxp-api-1.4.2.jar中的maven包含冲突,但还没有找到解决方法。在Window>Preferences:java>installed JRE中添加新安装的java jdk/JRE。确保在项目中JavaSE-11被用作执行环境。啊,好的,那么你的,换句话说,你的源和目标级别是11
,对吗?然后我的问题是:您的JAVA_HOME
集合如何,您的Eclipse运行在什么JVM中?我面临着同样的问题,可以确认它发生在Oracle JDK 11.0.2和Open JDK 11.0.2 for Windows上(对于它们,不需要Maven依赖项,因为类是JDK的一部分)。只是一个提示:调用Project->Clean。。。和Maven->更新项目。。。暂时为我解决了这个问题。我已经添加了
<?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>
<groupId>com.qlsdistribution.fps</groupId>
<artifactId>fpsproduction</artifactId>
<version>1.0.53</version>
<packaging>jar</packaging>
<name>fps-production</name>
<description>FocalPoint Sever Production Tool</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.11</java.version>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
<build.unknown>UNKNOWN</build.unknown>
<build.number>${build.unknown}</build.number>
<build.revision>${build.unknown}</build.revision>
<build.time>${maven.build.timestamp}</build.time>
</properties>
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!-- javax.validation -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml/jaxp-api -->
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxp-api</artifactId>
<version>1.4.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.annotation/jsr250-api -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>11</release>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<Implementation-Version>${project.version}-${build.number}(${build.time})</Implementation-Version>
<Implementation-Build>${build.number}</Implementation-Build>
<Implementation-SCM-Revision>${build.revision}</Implementation-SCM-Revision>
<Build-Time>${build.time}</Build-Time>
</manifestEntries>
</archive>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<release>11</release>
</configuration>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.8.RELEASE</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/assembly/bundle.xml</descriptor>
</descriptors>
<release>11</release>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<release>11</release>
</configuration>
<executions>
<execution>
<id>copy-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.outputDirectory}/static/docs
</outputDirectory>
<resources>
<resource>
<directory>
${project.build.directory}/generated-docs
</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<!-- Dev Tools -->
<profile>
<!-- Need to specify normal profile as well when using this one -->
<id>devtools</id>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</profile>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<filter>dev</filter>
</properties>
</profile>
</profiles>
</project>