小编Zah*_*ain的帖子

需要帮助:引起:java.lang.NullPointerException:无法调用“String.contains(java.lang.CharSequence)”,因为“变量”为空

我正在尝试将 SpringBoot 版本从 2.1.1 升级到 2.7.x (2.7.5){Java 版本 - 17},当我尝试运行我的应用程序时,收到以下错误消息

引起原因:java.lang.NullPointerException:无法调用“String.contains(java.lang.CharSequence)”,因为“variable”在org.springframework.data.jpa.repository.query.QueryUtils.createCountQueryFor(QueryUtils.java: 607)在org.springframework.data.jpa.repository.query.DefaultQueryEnhancer.createCountQueryFor(DefaultQueryEnhancer.java:49)在org.springframework.data.jpa.repository.query.StringQuery.deriveCountQuery(StringQuery.java:119)在org .springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.(AbstractStringBasedJpaQuery.java:72) 在 org.springframework.data.jpa.repository.query.NativeJpaQuery.(NativeJpaQuery.java:53) 在 org.springframework.data.jpa .repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:51) 在 org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:169) 在 org.springframework.data.jpa.repository .query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:253) 在 org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:93) 在 org.springframework.data.repository.core .support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:103) ... 省略 60 个常见框架

这是我的依赖项:


implementation 'org.springframework.boot:spring-boot:2.7.5'

    implementation('org.springframework.boot:spring-boot-starter-data-jpa')
    implementation('org.springframework.boot:spring-boot-starter-actuator')
    implementation('org.springframework.boot:spring-boot-starter-web')
    implementation('org.springframework.boot:spring-boot-starter-parent:2.7.5')

    implementation('org.springframework:spring-jdbc')
    implementation('org.springframework:spring-orm')
    implementation('org.springframework:spring-core')
    implementation('org.springframework:spring-beans')
    implementation('org.springframework:spring-webmvc')
    implementation('org.springframework:spring-web')
    implementation('org.springframework:spring-context')
    testImplementation 'org.springframework:spring-test:5.3.25'
    compileOnly group: 'javax.servlet', name: 'servlet-api', version: '2.5'
    runtime("org.springframework.boot:spring-boot-properties-migrator")
    compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
    implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.56'
    implementation group: 'org.hibernate', name: 'hibernate-core', version: '5.6.5.Final'
    implementation 'org.springframework.cloud:spring-cloud-context:3.1.0'
    implementation …
Run Code Online (Sandbox Code Playgroud)

nullpointerexception spring-data-jpa jpa-2.1 spring-boot java-17

8
推荐指数
1
解决办法
5276
查看次数