Heroku - błąd z kompilowaniem aplikacji w javie 16

0

Witam, macie może pomysł co zrobić, żeby aplikacja wrzucona na heroku kompilowała się w JDK 16, a nie 1.8? Próbowałem już wielu sposobów, oczywiście tak jak heroku zaleca stworzyłem plik system.properties, a w nim java.runtime.version=16, ale nic nie pomaga. Poniżej wrzucę jeszcze pom.xml, może tam czegoś brakuje. Będę bardzo wdzięczny za wszelką pomoc, z góry dziękuję i pozdrawiam.

<?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.5.1</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

	<properties>
		<java.version>16.0.1</java.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
			<version>2.5.1</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<version>2.5.1</version>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>8.0.25</version>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-core</artifactId>
			<version>2.12.3</version>
		</dependency>

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


	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<excludes>
						<exclude>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok</artifactId>
						</exclude>
					</excludes>
				</configuration>
			</plugin>
		</plugins>
	</build>

</project>

0

@viruis: po pierwsze to wyrzuciłbym maven-compiler-plugin z zależności i przeniósł do pluginów, i tam wskazał:

<!-- prev settings -->
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.2</version>
        
        <configuration>
            <release>16</release>
        </configuration>
    </plugin>
    <!-- other plugins -->
</plugins>

Ewentualnie możesz pokombinować z innymi ustawieniami: https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

1

O Heroku nic nie wiem, ale z obawą bym widział kierunkowanie się na najnowsze ciepłe wersje Javy, gdy mój projekt jest zanurzony w jakimś wielkim projekcie z rynku (na zasadzie 'w kontenerze', ale też na innych zasadach)
W swoim czasie trzeba było się lekko przyhamowywac (około v.14-15 ???) ze względu na kompatybilność Tomcata i innych środowisk.
Pewien konserwatyzm tam obowiązuje, i osobiście widzę w tym również zalety.

Przypomnę, że wersja LTS to ciągle 11, i tej mamy uzasadnione prawo oczekiwać jako wspólnego mianownika

@viruis
Jakie masz "dowody" np wypisy z logów, bo na razie to jest na nasz "ulubiony" sposób czyli "nie działa"

0

@AnyKtokolwiek: Przy javie w wersji 15 czy 11 był ten sam problem, jedynie java w wersji 8 normalnie ruszyła. Oczywiście, już podsyłam logi:

-----> Using buildpack: heroku/java
-----> Java app detected
-----> Installing JDK 1.8... done
-----> Executing Maven
       $ ./mvnw -DskipTests clean dependency:list install
       [INFO] Scanning for projects...
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.6.2/maven-compiler-plugin-3.6.2.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.6.2/maven-compiler-plugin-3.6.2.pom (11 kB at 19 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/30/maven-plugins-30.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/30/maven-plugins-30.pom (10 kB at 407 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.6.2/maven-compiler-plugin-3.6.2.jar
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.6.2/maven-compiler-plugin-3.6.2.jar (75 kB at 875 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/com/heroku/sdk/heroku-maven-plugin/3.0.3/heroku-maven-plugin-3.0.3.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/heroku/sdk/heroku-maven-plugin/3.0.3/heroku-maven-plugin-3.0.3.pom (4.1 kB at 203 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/com/heroku/sdk/heroku-sdk-parent/3.0.3/heroku-sdk-parent-3.0.3.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/heroku/sdk/heroku-sdk-parent/3.0.3/heroku-sdk-parent-3.0.3.pom (6.1 kB at 288 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/com/heroku/sdk/heroku-maven-plugin/3.0.3/heroku-maven-plugin-3.0.3.jar
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/heroku/sdk/heroku-maven-plugin/3.0.3/heroku-maven-plugin-3.0.3.jar (26 kB at 945 kB/s)
       [INFO] 
       [INFO] ---------------------------< pl.test:Test >---------------------------
       [INFO] Building Test 0.0.1-SNAPSHOT
       [INFO] --------------------------------[ jar ]---------------------------------
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/mysql/mysql-connector-java/8.0.25/mysql-connector-java-8.0.25.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/mysql/mysql-connector-java/8.0.25/mysql-connector-java-8.0.25.pom (2.5 kB at 119 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/mysql/mysql-connector-java/8.0.25/mysql-connector-java-8.0.25.jar
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/mysql/mysql-connector-java/8.0.25/mysql-connector-java-8.0.25.jar (2.4 MB at 6.3 MB/s)
       [INFO] 
       [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ Test ---
       [INFO] 
       [INFO] --- maven-dependency-plugin:3.1.2:list (default-cli) @ Test ---
       [INFO] 
       [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ Test ---
       [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 1 resource
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.6.2:compile (default-compile) @ Test ---
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/ow2/asm/asm/6.0_ALPHA/asm-6.0_ALPHA.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/ow2/asm/asm/6.0_ALPHA/asm-6.0_ALPHA.pom (1.9 kB at 114 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/ow2/asm/asm-parent/6.0_ALPHA/asm-parent-6.0_ALPHA.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/ow2/asm/asm-parent/6.0_ALPHA/asm-parent-6.0_ALPHA.pom (5.5 kB at 393 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/ow2/ow2/1.3/ow2-1.3.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/ow2/ow2/1.3/ow2-1.3.pom (9.5 kB at 634 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/2.0-M6/qdox-2.0-M6.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/2.0-M6/qdox-2.0-M6.pom (16 kB at 1.2 MB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-api/2.8.2/plexus-compiler-api-2.8.2.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-api/2.8.2/plexus-compiler-api-2.8.2.pom (867 B at 58 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler/2.8.2/plexus-compiler-2.8.2.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler/2.8.2/plexus-compiler-2.8.2.pom (4.9 kB at 376 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-manager/2.8.2/plexus-compiler-manager-2.8.2.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-manager/2.8.2/plexus-compiler-manager-2.8.2.pom (692 B at 53 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-javac/2.8.2/plexus-compiler-javac-2.8.2.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-javac/2.8.2/plexus-compiler-javac-2.8.2.pom (771 B at 35 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compilers/2.8.2/plexus-compilers-2.8.2.pom
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compilers/2.8.2/plexus-compilers-2.8.2.pom (1.3 kB at 96 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-component-annotations/1.6/plexus-component-annotations-1.6.jar
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/ow2/asm/asm/6.0_ALPHA/asm-6.0_ALPHA.jar
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/2.0-M6/qdox-2.0-M6.jar
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-component-annotations/1.6/plexus-component-annotations-1.6.jar (4.3 kB at 328 kB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-utils/3.1.0/maven-shared-utils-3.1.0.jar
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-api/2.8.2/plexus-compiler-api-2.8.2.jar
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-manager/2.8.2/plexus-compiler-manager-2.8.2.jar
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/ow2/asm/asm/6.0_ALPHA/asm-6.0_ALPHA.jar (56 kB at 1.1 MB/s)
       [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-javac/2.8.2/plexus-compiler-javac-2.8.2.jar
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-manager/2.8.2/plexus-compiler-manager-2.8.2.jar (4.7 kB at 61 kB/s)
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-javac/2.8.2/plexus-compiler-javac-2.8.2.jar (20 kB at 242 kB/s)
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-api/2.8.2/plexus-compiler-api-2.8.2.jar (26 kB at 254 kB/s)
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-utils/3.1.0/maven-shared-utils-3.1.0.jar (164 kB at 1.4 MB/s)
       [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/2.0-M6/qdox-2.0-M6.jar (314 kB at 1.8 MB/s)
       [INFO] Changes detected - recompiling the module!
       [INFO] Compiling 4 source files to /tmp/build_ab1b8f1f/target/classes
       [INFO] ------------------------------------------------------------------------
       [INFO] BUILD FAILURE
       [INFO] ------------------------------------------------------------------------
       [INFO] Total time:  5.383 s
       [INFO] Finished at: 2021-07-02T11:52:13Z
       [INFO] ------------------------------------------------------------------------
       [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.2:compile (default-compile) on project Test: Fatal error compiling: invalid flag: --release -> [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
 !     ERROR: Failed to build app with Maven
       We're sorry this build is failing! If you can't find the issue in application code,
       please submit a ticket so we can help: https://help.heroku.com/
 !     Push rejected, failed to compile Java app.
 !     Push failed
1

Fatal error compiling: invalid flag: --release

Sprawdziłbym jak dobrać wersje pluginu Mavena do wersji Javy i jak z niego poprawnie korzystać. Na pewno jest coś na Baeldungu :)

1
    <properties>
        <java.version>16</java.version>
    </properties>

1

Mam projekt w dżawie 16 z mavenem i jego konfiguracja wygląda tak:

     <plugin> //sekcja plugin w w sekcji build
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <source>16</source>
          <target>16</target>
          <compilerArgs>--enable-preview</compilerArgs> //to flaga do preview, nie wiem czy Ci potrzebna.
        </configuration>
      </plugin>

Na pewno nigdy nie podawało wersji minor i patcha w mavenie, tylko major.

Edit: faktycznie @Shalom ma racje. Po prostu w java.version wystarczy sam major version czyli 16.

1 użytkowników online, w tym zalogowanych: 0, gości: 1