1

I have tried to build a springboot application via commandpromt using command mvn clean install but its giving following error:

[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

I am using java 8 and spring boot 2.2.1.Release .PFB the image.

enter image description here

PFB the pom file:

<?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>

I have done the following things: --> tried to delete the repository from .m2 folder. -->Added maven complier plugin in pom.

I am having these much things in jaxb-api folder:

enter image description here

Could you please help me to resolve this issue.

SHILPA
  • 57
  • 1
  • 3
  • 11
  • The `javax.xml.bind.annotation` package should be in the `jaxb-api` jar file. I'd double check that the copy of that file in your `.m2/repository` is a valid zip file and contains the expected classes. – Andy Wilkinson Jun 11 '21 at 17:05
  • Could you please mention the path of jax-api in .m2/repository folder – SHILPA Jun 11 '21 at 17:09
  • I have added the screenshot in question – SHILPA Jun 11 '21 at 17:11
  • It's derived from the module's group ID, artifact ID, and version. `.`s in the group ID are replaced with `/`s. In this case, that gives a path of `.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar`. The same pattern is used for every dependency that Maven downloads. – Andy Wilkinson Jun 11 '21 at 17:13
  • The screenshot shows 2.3.0 and your pom has `2.3.1` so something's out of sync here. Similarly your pom shows you're using Spring Boot 2.2.1.RELEASE but in the question you've said you're using 2.1.4. – Andy Wilkinson Jun 11 '21 at 17:14
  • Changed the screenshot. Sorry the springboot version was a typo. – SHILPA Jun 11 '21 at 17:16
  • 1
    Iam getting this isuue while running via command promt.If I run via Eclipse using command clean install -X its becoming success – SHILPA Jun 11 '21 at 17:41
  • I solved this issue by using Java 8 (instead of Java 11 in my case) – dbaltor Mar 31 '23 at 13:49

2 Answers2

0

I was using JDK 11 and when I pointed my JAVA_HOME and Path environment values to JDK 1.8.0_311. This issue got resolved. Hope it helps

Himanshu
  • 9
  • 1
0

This might be bit late but can be helpful to anyone facing the same issue. I resolved it by updating SDK version in Project Structure window. In IntelliJ, navigate to File -> Project Structure -> Project Settings -> Project SDKs -> Select the valid SDK in your machine(For me, it was 1.8 java version)

Then build the project or do mvn clean install

Akanksha_p
  • 916
  • 12
  • 20