我一直在尝试使用 git hub 存储库在 heroku 上部署 Spring Boot 项目,但我不断收到错误:
[错误] 无法在项目慈善机构上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile): 致命编译错误: 无效目标版本: 12 -> [帮助1]
我尝试按照 Heroku 上的建议创建 system.properties:
java.runtime.version=12 maven.version=3.7.0
并将heroku插件添加到pom.xml。
我正在复制下面的 pom.xml 文件:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>pl.coderslab</groupId>
<artifactId>charity</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>charity</name>
<properties>
<java.version>12</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.9.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.8.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
</dependency>
<dependency>
<groupId>javax.activation</groupId><artifactId>activation</artifactId>
<version>1.1.1</version></dependency>
<dependency>
<groupId>javax.xml.bind</groupId><artifactId>jaxb-api</artifactId>
<version>2.3.0</version></dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId><artifactId>jaxb-core</artifactId>
<version>2.3.0</version></dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId><artifactId>jaxb-impl</artifactId>
<version>2.3.0</version></dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
我错过了什么?
最佳答案
修改您的 system.properties
文件,使其看起来完全像这样:
java.runtime.version=12
然后确保它已提交到 Git 并使用 git ls-files
推送到 Github。
你不需要maven.version
,如果你想控制你的maven版本,你应该使用Maven Wrapper .
关于java - 在heroku上部署项目时如何修复maven插件和java版本错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58641148/