阅读背景:

Pivot Cloud Foundry错误:“浏览器检测失败,系统属性h2.browser未设置” - Spring Boot 2

来源:互联网 

I'm trying to cf push my spring boot app to Pivot Cloud Foundry, but the container fails to start. This is the error output:

我正在尝试将我的Spring启动应用程序推送到Pivot Cloud Foundry,但容器无法启动。这是错误输出:

   2018-08-21T12:48:55.34+0200 [CELL/0] OUT Starting health monitoring of container
   2018-08-21T12:48:55.81+0200 [APP/PROC/WEB/0] OUT JVM Memory Configuration: -Xmx427509K -Xss1M -XX:ReservedCodeCacheSize=240M -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=109066K
   2018-08-21T12:48:55.81+0200 [APP/PROC/WEB/0] OUT Failed to start a browser to open the URL https://10.246.203.10:8082: Browser detection failed and system property h2.browser not set
   2018-08-21T12:49:56.15+0200 [HEALTH/0] ERR Failed to make TCP connection to port 8080: connection refused
   2018-08-21T12:49:56.15+0200 [CELL/0] ERR Timed out after 1m0s: health check never passed.

I tried to set the h2.browser property to "opera", false and true in Application.yml but that did not solve the problem. I also removed the h2 dependency because I don't want to use h2 in PCF and rebuilded the artifact before cf push. When I run the JAR file, it opens my browser with the h2 webinterface (I don't want that).

我试图在Application.yml中将h2.browser属性设置为“opera”,false和true,但这并没有解决问题。我还删除了h2依赖项,因为我不想在PCF中使用h2并在cf push之前重建了工件。当我运行JAR文件时,它会使用h2 webinterface打开我的浏览器(我不希望这样)。

What am I missing here?

我在这里想念的是什么?

EDIT: I think I might need to pass an argument to the java app in PCF to disable the console (browser part) of H2 but not sure..

编辑:我想我可能需要将参数传递给PCF中的java应用程序以禁用H2的控制台(浏览器部分)但不确定..

Application.yml:

Application.yml:

  datasource:
    driverClassName: com.mysql.jdbc.Driver
    url: jdbc:mysql://my_url_here
    username: my_username_here
    password: my_password_here
  jpa:
    hibernate.ddl-auto: none
    show_sql: false

manifest.yml

manifest.yml

---
applications:
- name: cookie-backend
  memory: 1024M
  instances: 1
  random-route: true
  buildpack: java_buildpack
  path: out/artifacts/cookie_backend_jar/cookie-backend.jar
  services:
  - mysql

pom.xml

的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com</groupId>
    <artifactId>cookie</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>cookie</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.javafaker</groupId>
            <artifactId>javafaker</artifactId>
            <version>0.15</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

1 个解决方案

#1


1  

I solved it by first starting a new Spring project, secondly importing all the dependancies in my new project POM file and and than adding back all classes (code) in that order. I ended up with a new project on the same codebase without the error.

我通过首先启动一个新的Spring项目来解决它,然后在我的新项目POM文件中导入所有依赖项,然后按顺序添加所有类(代码)。我最后在相同的代码库上创建了一个没有错误的新项目。

This is not the exact answer to what was going wrong with it, but it might be helpfull for someone trying to solve the same problem. I'm using h2 now on a production server. Also, the answer from @Daniel in respond to the issue might be helpful.

这不是解决问题的确切答案,但对于试图解决同样问题的人来说可能会有所帮助。我现在在生产服务器上使用h2。此外,@丹尼尔回答这个问题的答案可能会有所帮助。


分享到: