Spring Boot 2,LiquiGraph和503错误与Actuator健康终点 - org.springframework.jdbc.UncategorizedSQLException

时间:2018-01-08 17:47:45

标签: spring-boot spring-jdbc spring-data-neo4j spring-boot-actuator liquigraph

在我的Spring Boot 2.0.0.M6应用程序中,我使用以下Maven依赖项安装了LiquiGraph:

engine.io

我也使用Spring Data Neo4j 5,这是我的Neo4j配置:

    dependency>
        <groupId>org.liquigraph</groupId>
        <artifactId>liquigraph-spring-boot-starter</artifactId>
        <version>3.0.2</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-jdbc-bolt</artifactId>
        <version>3.1.0</version>
    </dependency>

现在,我的Spring Boot Actuator运行状况端点以@Configuration @EnableNeo4jRepositories(basePackages = "com.example.domain.repository.neo4j") @EnableTransactionManagement public class Neo4jConfig { @Value("${neo4j.bolt.server.database.uri}") private String boltServerDatabaseUri; @Value("${neo4j.jdbc.server.database.uri}") private String jdbcServerDatabaseUri; @Value("${neo4j.username}") private String username; @Value("${neo4j.password}") private String password; @Bean public Neo4jTransactionManager transactionManager() { return new Neo4jTransactionManager(sessionFactory()); } @Bean public SessionFactory sessionFactory() { return new SessionFactory(configuration(), "com.example.domain.model.neo4j"); } @Bean @DependsOn("liquigraph") public org.neo4j.ogm.config.Configuration configuration() { // @formatter:off return new org.neo4j.ogm.config.Configuration.Builder() .autoIndex("validate") .credentials(username, password) .uri(boltServerDatabaseUri) .build(); // @formatter:on } @Bean public DataSource dataSource() { final HikariConfig config = new HikariConfig(); config.setJdbcUrl(jdbcServerDatabaseUri); config.setUsername(username); config.setPassword(password); return new HikariDataSource(config); } } 响应并且JSON内部出现以下错误:

  

org.springframework.jdbc.UncategorizedSQLException

503 Status code

这可能是什么原因以及如何解决?

已更新

这是我的项目Maven依赖树:

{
  "status": "DOWN",
  "details": {
    "elasticsearch": {
      "status": "UP",
      "details": {
        "clusterName": "elasticsearch",
        "numberOfNodes": 1,
        "numberOfDataNodes": 1,
        "activePrimaryShards": 15,
        "activeShards": 15,
        "relocatingShards": 0,
        "initializingShards": 0,
        "unassignedShards": 15
      }
    },
    "diskSpace": {
      "status": "UP",
      "details": {
        "total": 120031539200,
        "free": 78051127296,
        "threshold": 10485760
      }
    },
    "mongo": {
      "status": "UP",
      "details": {
        "version": "3.4.6"
      }
    },
    "db": {
      "status": "DOWN",
      "details": {
        "database": "Neo4j",
        "error": "org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [SELECT 1]; SQL state [null]; error code [0]; Some errors occurred : \n[Neo.ClientError.Statement.SyntaxError]:Invalid input 'L': expected 't/T' (line 1, column 3 (offset: 2))\n\"SELECT 1\"\n   ^\n; nested exception is java.sql.SQLException: Some errors occurred : \n[Neo.ClientError.Statement.SyntaxError]:Invalid input 'L': expected 't/T' (line 1, column 3 (offset: 2))\n\"SELECT 1\"\n   ^\n"
      }
    },
    "neo4j": {
      "status": "UP",
      "details": {
        "nodes": 194
      }
    }
  }
}

2 个答案:

答案 0 :(得分:3)

<强> TL;博士;

management.health.db.enabled=false添加到您的配置中。

<强>详情

因为您还在配置中注册JDBC DataSource以使用liquigraph,所以SpringBoot的自动配置启动并为此db注册一个额外的HealthIndicator。您可以通过设置management.health.db.enabled=false

来停用此指标

如果您打算升级到SpringBoot 2.0.0.M7,请为您提供更多信息:运行状况检查的配置已更改为:

management.endpoint.health.enabled=true
management.endpoint.health.show-details=ALWAYS
management.health.db.enabled=false

答案 1 :(得分:0)

作为替代解决方法,您仍然可以通过以下方式获取数据源的运行状况检查,从而有效地隐藏自动配置的DataSourceHealthIndicator bean:

@Bean 
public DataSourceHealthIndicator dataSourceHealthIndicator(DataSource datasource) {
    return new DataSourceHealthIndicator(datasource, "match (n) return count(n) as nodes");
}