Spring Boot 无法在Openshift中部署Sping Boot 应用程序

x4shl7ld  于 2024-01-06  发布在  Spring
关注(0)|答案(2)|浏览(284)

我正在按照以下步骤运行我的Sping Boot 应用程序:https://github.com/debasen/springboot-demo.git in Open shift
1.将红帽OpenJDK 8添加到我的项目中。


2.下一个

3.添加命中存储库

在这样做之后。我在构建时得到以下日志:

  1. Cloning "https://github.com/debasen/springboot-demo.git " ...
  2. Commit: c3b500b7c27540de6f1ef90734aca8b1a09d6fb6 (Initial Commit)
  3. Author: Admin <Admin@DESKTOP-78DNBRA>
  4. Date: Sun Mar 18 20:48:29 2018 +0530
  5. Pulling image "registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift@sha256:afe904fd986c4147d1905813eb1a2f5bc3480ecad5b70b4ccfec384271777429" ...
  6. ==================================================================
  7. Starting S2I Java Build .....
  8. S2I source build with plain binaries detected
  9. Copying binaries from /tmp/src to /deployments ...
  10. ... done
  11. Pushing image docker-registry.default.svc:5000/boot-test1/spring-demo:latest ...
  12. Push successful

字符串
部署失败,并显示以下日志:

  1. Starting the Java application using /opt/run-java/run-java.sh ...
  2. ERROR: Neither $JAVA_MAIN_CLASS nor $JAVA_APP_JAR is set and 0 JARs found in /deployments (1 expected)
  3. exec java -javaagent:/opt/jolokia/jolokia.jar=config=/opt/jolokia/etc/jolokia.properties -Xms256m -Xmx256m -XX:+UseParallelGC -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MaxMetaspaceSize=100m -XX:ParallelGCThreads=1 -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -XX:CICompilerCount=2 -XX:+ExitOnOutOfMemoryError -cp . -jar
  4. Error: -jar requires jar file specification
  5. Usage: java [-options] class [args...]
  6. (to execute a class)
  7. or java [-options] -jar jarfile [args...]
  8. (to execute a jar file)
  9. where options include:
  10. -d32 use a 32-bit data model if available
  11. -d64 use a 64-bit data model if available
  12. -server to select the "server" VM
  13. The default VM is server,
  14. because you are running on a server-class machine.
  15. -cp <class search path of directories and zip/jar files>
  16. -classpath <class search path of directories and zip/jar files>
  17. A : separated list of directories, JAR archives,
  18. and ZIP archives to search for class files.
  19. -D<name>=<value>
  20. set a system property
  21. -verbose:[class|gc|jni]
  22. enable verbose output
  23. -version print product version and exit
  24. -version:<value>
  25. Warning: this feature is deprecated and will be removed
  26. in a future release.
  27. require the specified version to run
  28. -showversion print product version and continue
  29. -jre-restrict-search | -no-jre-restrict-search
  30. Warning: this feature is deprecated and will be removed
  31. in a future release.
  32. include/exclude user private JREs in the version search
  33. -? -help print this help message
  34. -X print help on non-standard options
  35. -ea[:<packagename>...|:<classname>]
  36. -enableassertions[:<packagename>...|:<classname>]
  37. enable assertions with specified granularity
  38. -da[:<packagename>...|:<classname>]
  39. -disableassertions[:<packagename>...|:<classname>]
  40. disable assertions with specified granularity
  41. -esa | -enablesystemassertions
  42. enable system assertions
  43. -dsa | -disablesystemassertions
  44. disable system assertions
  45. -agentlib:<libname>[=<options>]
  46. load native agent library <libname>, e.g. -agentlib:hprof
  47. see also, -agentlib:jdwp=help and -agentlib:hprof=help
  48. -agentpath:<pathname>[=<options>]
  49. load native agent library by full pathname
  50. -javaagent:<jarpath>[=<options>]
  51. load Java programming language agent, see java.lang.instrument
  52. -splash:<imagepath>
  53. show splash screen with specified image
  54. See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.


由于在构建时没有创建jar,因此部署失败。虽然示例存储库https://github.com/jboss-openshift/openshift-quickstarts中的项目工作正常。我尝试Heroku托管我的应用程序。它在Heroku中工作正常。但在Openshift中不工作。请告诉我我错过了什么。

rt4zxlrg

rt4zxlrg1#

构建日志没有报告显式错误,但表明实际上没有构建任何内容:

  1. S2I source build with plain binaries detected
  2. Copying binaries from /tmp/src to /deployments ...
  3. ... done

字符串
由于your repo将应用源代码“隐藏”在父文件夹中,请尝试为构建版本指定contextDir(默认情况下为/)为springboot-demo,或者将应用源代码移动到git存储库的根目录。
您可以通过oc edit bc/<build_config_name>使用oc CLI编辑构建配置,或者在从目录部署应用程序期间提供git repo URL时,通过单击 “高级选项” 链接使用Web界面进行编辑,或者在浏览现有构建配置时使用 * 操作 * -> * 编辑 * 菜单项进行编辑。

7lrncoxx

7lrncoxx2#

我得到了同样的错误。然而,对我来说,解决方案是让应用程序产生Jar而不是War
我使用maven来打包应用程序。

  1. <packaging>war</packaging>

字符串

  1. <packaging>jar</packaging>

相关问题