首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >包javax.xml.bind.annotation不存在

包javax.xml.bind.annotation不存在
EN

Stack Overflow用户
提问于 2021-06-11 16:52:53
回答 2查看 7.9K关注 0票数 1

我曾尝试使用命令mvn清洁安装通过命令mvn构建一个giving引导应用程序,但是它给出了以下错误:

代码语言:javascript
复制
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project infytel_demo7_a: Compilation failure: Compilation failure:
[ERROR] /C:/Users/shilpa.nair01/Desktop/spring boot lex/Spring REST demos with script/infytel_demo7_validation/infytel_demo7a/src/main/java/com/infytel/dto/PlanDTO.java:[3,33] package javax.xml.bind.annotation does not exist
[ERROR] /C:/Users/shilpa.nair01/Desktop/spring boot lex/Spring REST demos with script/infytel_demo7_validation/infytel_demo7a/src/main/java/com/infytel/dto/PlanDTO.java:[5,2] cannot find symbol
[ERROR] symbol: class XmlRootElement
[ERROR] /C:/Users/shilpa.nair01/Desktop/spring boot lex/Spring REST demos with script/infytel_demo7_validation/infytel_demo7a/src/main/java/com/infytel/dto/EntityList.java:[6,33] package javax.xml.bind.annotation does not exist
[ERROR] /C:/Users/shilpa.nair01/Desktop/spring boot lex/Spring REST demos with script/infytel_demo7_validation/infytel_demo7a/src/main/java/com/infytel/dto/EntityList.java:[7,33] package javax.xml.bind.annotation does not exist
[ERROR] /C:/Users/shilpa.nair01/Desktop/spring boot lex/Spring REST demos with script/infytel_demo7_validation/infytel_demo7a/src/main/java/com/infytel/dto/EntityList.java:[8,33] package javax.xml.bind.annotation does not exist
[ERROR] /C:/Users/shilpa.nair01/Desktop/spring boot lex/Spring REST demos with script/infytel_demo7_validation/infytel_demo7a/src/main/java/com/infytel/dto/EntityList.java:[10,2] cannot find symbol
[ERROR] symbol: class XmlRootElement
[ERROR] /C:/Users/shilpa.nair01/Desktop/spring boot lex/Spring REST demos with script/infytel_demo7_validation/infytel_demo7a/src/main/java/com/infytel/dto/EntityList.java:[11,2] cannot find symbol

我使用的是java 8和spring 2.2.1。释放 .PFB映像。

PFB pom文件:

代码语言:javascript
复制
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.infytel</groupId>
    <artifactId>infytel_demo7_a</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>infytel_demo7_a</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- Stuff related to XML serialization and deserialization -->
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
             <version>2.3.1</version>
        </dependency>
        <!-- Stuff related to XML serialization and deserialization -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>


    </dependencies>

    <build>
        <plugins>
        
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
            </plugin>
        </plugins>
    </build>

</project>

我做了以下工作:->尝试从.m2文件夹中删除存储库。

我在jaxb-api文件夹中有很多东西:

你能帮我解决这个问题吗?

EN

回答 2

Stack Overflow用户

发布于 2022-04-08 06:27:37

当我将JAVA_HOME和Path环境值指向JDK 1.8.0_311时,我正在使用JDK 11。这个问题解决了。希望它能帮上忙

票数 0
EN

Stack Overflow用户

发布于 2022-07-04 03:04:00

这可能有点晚,但对任何面临同样问题的人都有帮助。我通过在项目结构窗口中更新SDK版本来解决这个问题。在IntelliJ中,导航到 ->项目结构->项目设置->项目SDK ->在计算机中选择有效的SDK(对我来说,它是1.8java版本)

然后构建项目或执行mvn clean install

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67940799

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档