为 springboot 应用程序部署 Heroku 失败?

时间:2021-06-15 12:32:41

标签: java spring-boot heroku

尝试在 Heroku 云中部署 spring-boot 应用程序,出现编译 java 应用程序失败的错误,但这在我的本地机器上运行良好。

       [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project smartcontactmanager: Compilation failure
       [ERROR] /tmp/build_f6591bb6/src/main/java/com/smart/config/CustomUserDetails.java:[29,28] cannot find symbol
       [ERROR]   symbol:   method of(org.springframework.security.core.authority.SimpleGrantedAuthority)
       [ERROR]   location: interface java.util.List
       [ERROR] -> [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/MojoFailureException
 !     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 个答案:

答案 0 :(得分:0)

您似乎在默认 JDK (OpenJDK 8) 上运行,但您的代码使用了 List.of,后来添加 (Java 9)。

位于项目根目录下的 system.properties 文件中的

Set the desired Java 版本

java.runtime.version=9