I have just downloaded from spring.io a project with the only "web" dependency. Here's the 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 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.7.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>microservices.book</groupId>
<artifactId>social-multiplication</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>social-multiplication</name>
<description>Social Multiplication App</description>
<properties>
<java.version>18</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<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>
</plugins>
</build>
</project>
When from the terminal I give:
mvn spring-boot:run
I get:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------< microservices.book:social-multiplication >--------------
[INFO] Building social-multiplication 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.7.3:run (default-cli) > test-compile @ social-multiplication >>>
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ social-multiplication ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ social-multiplication ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\Massimo\Desktop\Programming\social-multiplication\social-multiplication\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.084 s
[INFO] Finished at: 2022-09-11T23:25:39+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project social-multip
lication: Fatal error compiling: invalid target release: 18 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
I've looked both at this and this SO question but that's not my case.
> echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_161
> echo %JAVA_jdk%
C:\Program Files\Java\jdk1.8.0_161
and I'm trying to build a java 18 application.
So what's the problem? Also I would like to know something about the maven specified in the pom. It's not the "standard" maven that I call from the terminal right? What artifat is it downloading?
I'm on windows 10, Intellij Idea 2020.2, and my maven version is:
> mvn --version
Maven home: C:\Program Files\apache-maven-3.8.6-bin\apache-maven-3.8.6
Java version: 1.8.0_161, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_161\jre
Default locale: it_IT, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windws"