Čamo
Čamo

Reputation: 4162

maven-compiler-plugin not found

I am learning Selenium and I would like to try add the maven-compiler-plugin to pom.xml and reimport maven settings. So I found this example to do it http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html and tried to add the code to the pom.xml. But the vrsion from the example 3.8.1 is red like on the screenshot. What it means? It is a copy from example.

enter image description here

Here is the whole pom.xml

<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>camaj.vladimir</groupId>
    <artifactId>selenium-maven</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>3.141.59</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>3.141.59</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>4.1.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.tempus-fugit</groupId>
            <artifactId>tempus-fugit</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>com.codeborne</groupId>
            <artifactId>phantomjsdriver</artifactId>
            <version>1.4.4</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Upvotes: 14

Views: 89613

Answers (12)

Pratibha Rai
Pratibha Rai

Reputation: 19

For me I was also facing this suddenly, I just did maven clean install. It worked for me!!!

Upvotes: 0

Sreekant Shenoy
Sreekant Shenoy

Reputation: 1618

One reason could be due to proxy setup on your system in Maven settings.

You can remove/backup the previous maven settings.xml file and this should work.

mv ~/.m2/settings.xml ~/.m2/settings.xml.bak

Upvotes: 0

cha_lar
cha_lar

Reputation: 134

In my case, Spring Boot code works fine without changing anything, however, it gives the same error when I tried to commit in Git.

To solve this, I add the version info as follows and it worked.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${maven-compiler-plugin.version}</version>
    ...

Upvotes: 8

Amit Sinha
Amit Sinha

Reputation: 614

I went to

.m2\repository\org\apache\maven\plugins\maven-compiler-plugin

and removed older version. It worked

Upvotes: 2

wxm146
wxm146

Reputation: 179

I got this error with IntelliJ. tried many ways, the below worked for me:

  1. Close your IDE.
  2. Delete "*.iml" and ".idea" -directories(present in the root folder of project)
  3. Run "mvn clean install" from the command-line
  4. Re-import your project into IDEA

Upvotes: 4

Victoria Agafonova
Victoria Agafonova

Reputation: 2178

I've faced this issue with my old project (which was 100% working on my old ItelliJ IDEA) and newly installed ItelliJ IDEA: in the pom.xml I had this:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
    </plugins>
</build>

And IDEA throwed an error maven-compiler-plugin not found. I've added

<groupId>org.apache.maven.plugins</groupId>

and IDEA found the plugin, and after that I was free to remove org.apache.maven.plugins without breaking IDEA

Upvotes: 4

electrobabe
electrobabe

Reputation: 1647

In my case the groupId for the plugin was missing:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.8.0</version>
...

Upvotes: 10

Eric Rommel
Eric Rommel

Reputation: 352

In my case, I have changed the tags from plugin to dependency like it is in the Maven Repository.

<dependency>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.8.1</version>
</dependency>

Upvotes: 13

Zakaria Shahed
Zakaria Shahed

Reputation: 2697

Add the Following code in your pom the issue will resolve

 <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>8</source>
                <target>8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M1</version>
            <configuration>
                <useSystemClassLoader>false</useSystemClassLoader>
                <forkCount>1</forkCount>
                <useFile>false</useFile>
                <skipTests>false</skipTests>
                <testFailureIgnore>true</testFailureIgnore>
                <forkMode>once</forkMode>
                <suiteXmlFiles>
                    <suiteXmlFile>testing.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Make sure you are reimporting your dependency after adding plugins

Upvotes: 1

Jemik Patel
Jemik Patel

Reputation: 1

You need to update your project so that the dependencies are updated from Maven side.

To update:

  1. Change the file structure to project view.
  2. Right click on project name -> Maven -> Reload project

And it will download all the necessary dependencies.

Upvotes: 0

andrea
andrea

Reputation: 49

In my case, invalidating cache and restarting solved the issue.

Upvotes: 2

SRav
SRav

Reputation: 31

In IntelliJ you can right click on 3.8.1 scroll down to Maven and select "Reimport". This solved the issue for me.

Upvotes: 3

Related Questions