JHipster项目集成spring-boot-starter-graphql端点未自动配置求助
排查JHipster集成spring-boot-starter-graphql无端点响应问题
我们正在开发基于JHipster的项目,需将一个使用spring-boot-starter-graphql的现有项目迁移至JHipster框架中。已在pom.xml中添加该依赖,按预期Spring Boot应自动配置GraphQL端点,但启动后控制台无相关日志输出,Servlet也无响应,推测是JHipster存在配置冲突或缺失。
相关pom.xml代码如下:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>involve.gbi.era4tb</groupId> <artifactId>era-4-tb</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>Era 4 Tb</name> <description>Description for era4tb</description> <repositories> <!-- jhipster-needle-maven-repository --> </repositories> <pluginRepositories> <!-- jhipster-needle-maven-plugin-repository --> </pluginRepositories> <!-- jhipster-needle-distribution-management --> <properties> <!-- Build properties --> <maven.version>3.2.5</maven.version> <java.version>14</java.version> <node.version>v16.17.0</node.version> <npm.version>8.19.1</npm.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format> <maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.target>${java.version}</maven.compiler.target> <start-class>involve.gbi.era4tb.Era4TbApp</start-class> <argLine>-Djava.security.egd=file:/dev/./urandom -Xmx1G</argLine> <m2e.apt.activation>jdt_apt</m2e.apt.activation> <run.addResources>false</run.addResources> <!-- These remain empty unless the corresponding profile is active --> <profile.no-liquibase /> <profile.api-docs /> <profile.tls /> <profile.e2e /> <!-- Dependency versions --> <jhipster-dependencies.version>7.9.3</jhipster-dependencies.version> <!-- The spring-boot version should match the one managed by https://mvnrepository.com/artifact/tech.jhipster/jhipster-dependencies/${jhipster-dependencies.version} --> <spring-boot.version>2.7.3</spring-boot.version> <!-- The hibernate version should match the one managed by https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/${spring-boot.version} --> <hibernate.version>5.6.10.Final</hibernate.version> <!-- The liquibase version should match the one managed by https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/${spring-boot.version} --> <liquibase.version>4.15.0</liquibase.version> <liquibase-hibernate5.version>4.15.0</liquibase-hibernate5.version> <validation-api.version>2.0.1.Final</validation-api.version> <jaxb-runtime.version>4.0.0</jaxb-runtime.version> <archunit-junit5.version>0.22.0</archunit-junit5.version> <mapstruct.version>1.5.2.Final</mapstruct.version> <!-- Plugin versions --> <maven-clean-plugin.version>3.2.0</maven-clean-plugin.version> <maven-site-plugin.version>3.12.1</maven-site-plugin.version> <maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version> <maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version> <maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version> <maven-enforcer-plugin.version>3.1.0</maven-enforcer-plugin.version> <maven-failsafe-plugin.version>3.0.0-M7</maven-failsafe-plugin.version> <maven-jar-plugin.version>3.2.2</maven-jar-plugin.version> <maven-idea-plugin.version>2.2.1</maven-idea-plugin.version> <maven-resources-plugin.version>3.3.0</maven-resources-plugin.version> <maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version> <maven-war-plugin.version>3.3.2</maven-war-plugin.version> <maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version> <checkstyle.version>10.3.2</checkstyle.version> <nohttp-checkstyle.version>0.0.10</nohttp-checkstyle.version> <frontend-maven-plugin.version>1.12.1</frontend-maven-plugin.version> <checksum-maven-plugin.version>1.11</checksum-maven-plugin.version> <maven-antrun-plugin.version>3.1.0</maven-antrun-plugin.version> <git-commit-id-plugin.version>5.0.0</git-commit-id-plugin.version> <modernizer-maven-plugin.version>2.4.0</modernizer-maven-plugin.version> <jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version> <jib-maven-plugin.version>3.2.1</jib-maven-plugin.version> <jib-maven-plugin.image>eclipse-temurin:11-jre-focal</jib-maven-plugin.image> <jib-maven-plugin.architecture>amd64</jib-maven-plugin.architecture> <lifecycle-mapping.version>1.0.0</lifecycle-mapping.version> <properties-maven-plugin.version>1.1.0</properties-maven-plugin.version> <sonar-maven-plugin.version>3.9.1.2184</sonar-maven-plugin.version> <!-- jhipster-needle-maven-property --> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>tech.jhipster</groupId> <artifactId>jhipster-dependencies</artifactId> <version>${jhipster-dependencies.version}</version> <type>pom</type> <scope>import</scope> </dependency> <!-- jhipster-needle-maven-add-dependency-management --> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>tech.jhipster</groupId> <artifactId>jhipster-framework</artifactId> </dependency> <dependency> <groupId>javax.annotation</groupId> <artifactId>javax.annotation-api</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-jaxb-annotations</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-hibernate5</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-hppc</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> </dependency> <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-webmvc-core</artifactId> </dependency> <dependency> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> <dependency> <groupId>javax.cache</groupId> <artifactId>cache-api</artifactId> </dependency> <dependency> <groupId>org.ehcache</groupId> <artifactId>ehcache</artifactId> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> </dependency> <dependency> <groupId>org.hibernate.validator</groupId> <artifactId>hibernate-validator</artifactId> </dependency> <dependency> <groupId>org.liquibase</groupId> <artifactId>liquibase-core</artifactId> <!-- Inherited version from Spring Boot can't be used because of regressions --> <version>${liquibase.version}</version> </dependency> <dependency> <groupId>org.mapstruct</groupId> <artifactId>mapstruct</artifactId> <version>${mapstruct.version}</version> </dependency> <dependency> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>${mapstruct.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-loader-tools</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.testcontainers</groupId> <artifactId>jdbc</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>com.tngtech.archunit</groupId> <artifactId>archunit-junit5-api</artifactId> <version>${archunit-junit5.version}</version> <scope>test</scope> </dependency> <!-- Adding the engine dependency to the surefire-plugin unfortunately does not work in the current version. --> <!-- https://www.archunit.org/userguide/html/000_Index.html#_junit_5 --> <dependency> <groupId>com.tngtech.archunit</groupId> <artifactId>archunit-junit5-engine</artifactId> <version>${archunit-junit5.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.zalando</groupId> <artifactId>problem-spring-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-undertow</artifactId> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-api</artifactId> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-impl</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-jackson</artifactId> <scope>runtime</scope> </dependency> <!-- Spring Cloud --> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-data</artifactId> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> </dependency> <dependency> <groupId>io.dropwizard.metrics</groupId> <artifactId>metrics-core</artifactId> </dependency> <!-- jhipster-needle-maven-add-dependency --> <dependency> <groupId>com.querydsl</groupId> <artifactId>querydsl-core</artifactId> <version>5.0.0</version> </dependency> <dependency> <groupId>com.querydsl</groupId> <artifactId>querydsl-apt</artifactId> <version>5.0.0</version> </dependency> <dependency> <groupId>com.querydsl</groupId> <artifactId>querydsl-jpa</artifactId> <version>5.0.0</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.9.1</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-graphql</artifactId> </dependency> <dependency> <groupId>com.graphql-java</groupId> <artifactId>graphql-java-extended-scalars</artifactId> <version>19.1</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.22</version> <scope>provided</scope> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.11.0</version> </dependency> <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-data-rest</artifactId> </dependency> </dependencies> </project>
排查方向
确认GraphQL Schema文件存在
Spring Boot GraphQL自动配置的触发条件是项目中存在.graphqls或.gqls格式的Schema文件,默认路径为src/main/resources/graphql/。如果没有该文件,自动配置逻辑不会执行,端点也不会创建。可以先添加一个简单的测试Schema验证:type Query { hello: String }检查JHipster Security拦截规则
JHipster默认的Security配置会拦截所有未授权的请求,GraphQL默认端点/graphql可能被拦截。需要在Security配置类中添加放行规则:@Override protected void configure(HttpSecurity http) throws Exception { super.configure(http); http.authorizeRequests() .antMatchers("/graphql", "/graphiql").permitAll(); }验证自动配置是否被禁用
检查application.yml或application.properties中是否存在spring.autoconfigure.exclude配置,确认是否包含了GraphQL相关的自动配置类,比如org.springframework.boot.autoconfigure.graphql.GraphQlAutoConfiguration。开启GraphQL调试日志
在配置文件
相关产品推荐
相关产品推荐

