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

x4shl7ld  于 11个月前  发布在  Spring
关注(0)|答案(2)|浏览(175)

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


2.下一个

3.添加命中存储库

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

Cloning "https://github.com/debasen/springboot-demo.git " ...
    Commit: c3b500b7c27540de6f1ef90734aca8b1a09d6fb6 (Initial Commit)
    Author: Admin <Admin@DESKTOP-78DNBRA>
    Date:   Sun Mar 18 20:48:29 2018 +0530
Pulling image "registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift@sha256:afe904fd986c4147d1905813eb1a2f5bc3480ecad5b70b4ccfec384271777429" ...
==================================================================
Starting S2I Java Build .....
S2I source build with plain binaries detected
Copying binaries from /tmp/src to /deployments ...
... done

Pushing image docker-registry.default.svc:5000/boot-test1/spring-demo:latest ...
Push successful

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

Starting the Java application using /opt/run-java/run-java.sh ...
ERROR: Neither $JAVA_MAIN_CLASS nor $JAVA_APP_JAR is set and 0 JARs found in /deployments (1 expected)
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
Error: -jar requires jar file specification
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32      use a 32-bit data model if available
    -d64      use a 64-bit data model if available
    -server   to select the "server" VM
                  The default VM is server,
                  because you are running on a server-class machine.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
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#

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

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

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

7lrncoxx

7lrncoxx2#

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

<packaging>war</packaging>

字符串

<packaging>jar</packaging>

相关问题