java - How to fix [Error] realm = plugin>org.apache.maven.plugins:maven-compiler-plugin:3.x (Happened while working on Spring Boot) -


problem

i decided spring boot hello word example work java 1.8 annoying dependency issues. in answer section explain solved problem hints on how bring on machine date. error getting was:

[error] realm =    plugin>org.apache.maven.plugins:maven-compiler-plugin:3.x [error] strategy = org.codehaus.plexus.classworlds.strategy.selffirststrategy [error] urls[0] = file:/users/xxx/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.jar [error] urls[1] = file:/users/xxx/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar [error] urls[2] = file:/users/xxx/repository/org/apache/maven/shared/maven-shared-utils/0.1/maven-shared-utils-0.1.jar [error] urls[3] = file:/users/xxx/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar [error] urls[4] = file:/users/xxx/.m2/repository/org/apache/maven/shared/maven-shared-incremental/1.1/maven-shared-incremental-1.1.jar [error] urls[5] = file:/users/xxx/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar [error] urls[6] = file:/users/xxx/.m2/repository/org/codehaus/plexus/plexus-compiler-api/2.2/plexus-compiler-api-2.2.jar [error] urls[7] = file:/users/xxx/.m2/repository/org/codehaus/plexus/plexus-compiler-manager/2.2/plexus-compiler-manager-2.2.jar [error] urls[8] = file:/users/xxx/.m2/repository/org/codehaus/plexus/plexus-compiler-javac/2.2/plexus-compiler-javac-2.2.jar [error] urls[9] = file:/users/xxx/.m2/repository/org/apache/xbean/xbean-reflect/3.4/xbean-reflect-3.4.jar [error] urls[10] = file:/users/xxx/.m2/repository/log4j/log4j/1.2.12/log4j-1.2.12.jar [error] urls[11] = file:/users/xxx/.m2/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar [error] urls[12] = file:/users/xxx/.m2/repository/com/google/collections/google-collections/1.0/google-collections-1.0.jar [error] urls[13] = file:/users/xxx/.m2/repository/junit/junit/3.8.2/junit-3.8.2.jar 

solutions didn't work

a lot of threads suggesting removing ~/.m2/ repositories here did not solve problem.

some others said due java 1.8 , works them java 1.7! couldn't believe them did not make sense. , wanted simple example work java 8.

solution summary

it dependency conflict had nothing java version or repositories under .m2 folder me.

the source of error dependency conflict caused plugin>org.apache.maven.plugins:maven-compiler-plugin:3.x.


other related sources

other questions on stackoverflow similar didn't solve problem spring boot follows:

1- maven-build-error-failed-to-execute-goal-missing-a-class

2- failed-to-execute-goal-org-apache-maven-pluginsmaven-compiler-plugin2-3-2comp

3- maven-release-plugin-issue-failed-to-execute-goal-org-apache-maven-pluginsmav

4- maven-archetype-problem

solution

as mentioned, source of error dependency conflict caused plugin>org.apache.maven.plugins:maven-compiler-plugin:3.x. based on comment made in cases specifying java version through <properties><java.version>1.8</java.version></properties> solves problem (based on guide here).

however in case (checkout specs) specifying maven compiler plugin , through following code solved problem:

<plugin>     <artifactid>maven-compiler-plugin</artifactid>     <version>2.3.2</version>     <configuration>         <source>1.8</source>         <target>1.8</target>     </configuration> </plugin> 

specs

  • java 1.8_45
  • maven 3.3.3
  • os x yosemite

files

basically had specify maven-compiler-plugin in pom.xml (see below).

pom.xml

<?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.mycompany</groupid>     <artifactid>helloworld</artifactid>     <version>0.1.0</version>     <!-- inherit defaults spring boot -->     <parent>         <groupid>org.springframework.boot</groupid>         <artifactid>spring-boot-starter-parent</artifactid>         <version>1.2.2.release</version>     </parent>     <dependencies>         <dependency>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-starter-web</artifactid>         </dependency>      </dependencies>     <build>         <plugins>              <plugin>                 <artifactid>maven-compiler-plugin</artifactid>                 <version>2.3.2</version>                 <configuration>                     <source>1.8</source>                     <target>1.8</target>                 </configuration>             </plugin>             <plugin>                 <groupid>org.springframework.boot</groupid>                 <artifactid>spring-boot-maven-plugin</artifactid>             </plugin>          </plugins>     </build> </project> 

samplecontoroller.java

import org.springframework.boot.*; import org.springframework.boot.autoconfigure.*; import org.springframework.web.bind.annotation.*;  @restcontroller @enableautoconfiguration public class samplecontroller {      @requestmapping("/")     string home() {         return "hello world!";     }      public static void main(string[] args) throws exception {         springapplication.run(samplecontroller.class, args);     } } 

project folder structure

just follow maven standard structure.

hint please feel free give me feedback in comments if solved problem, or if faced other issues.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -