Spring Boot 2,Java 10和QueryDsl - 从Spring Boot 1.5迁移到2

时间:2018-06-01 09:59:50

标签: java spring spring-boot jhipster querydsl

将Spring Boot 1.5应用程序(最初通过JHipster 4.13.3,使用Java 8和QueryDsl 4.1.4生成)迁移到Spring Boot 2.x(使用Java 10)。

使用QueryDsl在1.5中工作,现在使用2.x我得到以下构建错误,如:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project webfit: Compilation failure: Compilation failure:
[ERROR] .../WebConfigurer.java:[15,58] package org.springframework.boot.context.embedded.undertow does not exist
[ERROR] .../WebConfigurer.java:[35,66] cannot find symbol
[ERROR] symbol: class EmbeddedServletContainerCustomizer
[ERROR] .../WebConfigurer.java:[68,27] cannot find symbol
[ERROR] symbol:   class ConfigurableEmbeddedServletContainer
[ERROR] location: ...config.WebConfigurer
[ERROR] .../WebConfigurer.java:[93,45] cannot find symbol
[ERROR] symbol:   class ConfigurableEmbeddedServletContainer
[ERROR] location: class ...config.WebConfigurer
[ERROR] .../WebConfigurer.java:[14,1] package org.springframework.boot.context.embedded does not exist
[ERROR] .../ApplicationWebXml.java:[5,44] package org.springframework.boot.web.support does not exist
[ERROR] .../ApplicationWebXml.java:[11,40] cannot find symbol
[ERROR] symbol: class SpringBootServletInitializer
[ERROR] ...Repository.java:[5,41] cannot find symbol
[ERROR] symbol:   class QueryDslPredicateExecutor
[ERROR] location: package org.springframework.data.querydsl
[ERROR] ...Repository.java:[14,92] cannot find symbol
[ERROR] symbol: class QueryDslPredicateExecutor
[ERROR] ...Repository.java:[7,41] cannot find symbol
[ERROR] symbol:   class QueryDslPredicateExecutor
[ERROR] location: package org.springframework.data.querydsl
[ERROR] ...Repository.java:[15,90] cannot find symbol
[ERROR] symbol: class QueryDslPredicateExecutor
[ERROR] .../service/MailService.java:[16,29] package org.thymeleaf.spring4 does not exist
[ERROR] .../service/MailService.java:[41,19] cannot find symbol
[ERROR] symbol:   class SpringTemplateEngine
[ERROR] location: class ...service.MailService
[ERROR] .../service/MailService.java:[44,42] cannot find symbol
[ERROR] symbol:   class SpringTemplateEngine
[ERROR] location: class ...service.MailService
[ERROR] ...Repository.java:[7,41] cannot find symbol
[ERROR] symbol:   class QueryDslPredicateExecutor
[ERROR] location: package org.springframework.data.querydsl
[ERROR] ...Repository.java:[15,110] cannot find symbol
[ERROR] symbol: class QueryDslPredicateExecutor
[ERROR] ...App.java:[11,1] package org.springframework.boot.actuate.autoconfigure does not exist
[ERROR] ...Repository.java:[8,41] cannot find symbol
[ERROR] symbol:   class QueryDslPredicateExecutor
[ERROR] location: package org.springframework.data.querydsl
[ERROR] ...Repository.java:[16,95] cannot find symbol
[ERROR] symbol: class QueryDslPredicateExecutor
[ERROR] ...Repository.java:[5,41] cannot find symbol
[ERROR] symbol:   class QueryDslPredicateExecutor
[ERROR] location: package org.springframework.data.querydsl
[ERROR] ...Repository.java:[14,90] cannot find symbol
[ERROR] symbol: class QueryDslPredicateExecutor
[ERROR] ...App.java:[25,37] cannot find symbol
[ERROR] symbol: class MetricFilterAutoConfiguration
[ERROR] ...App.java:[25,74] cannot find symbol
[ERROR] symbol: class MetricRepositoryAutoConfiguration

如何解决这些问题?

在POM中我使用:

...
<jhipster-dependencies.version>2.0.2</jhipster-dependencies.version>
<spring-boot.version>2.0.2.RELEASE</spring-boot.version>
...

有趣的是,在Eclipse中,我在Maven Dependencies中看到了2.0.1的用法(但我指定了2.0.2),例如:

...
spring-boot-starter-2.0.1.RELEASE.jar
spring-boot-starter-cache-2.0.1.RELEASE.jar
spring-context-5.0.5.RELEASE.jar
spring-core-5.0.5.RELEASE.jar
spring-boot-actuator-2.0.1.RELEASE.jar
spring-boot-2.0.1.RELEASE.jar
spring-data-jpa-2.0.6.RELEASE.jar
spring-boot-starter-web-2.0.1.RELEASE.jar
...
jhipster-1.3.0.jar
...
hibernate-jcache-5.2.16.Final.jar
hibernate-core-5.2.16.Final.jar
hibernate-jpa-2.1-api-1.0.0.jar
hibernate-commons-annotations-5.0.1.Final.jar
hibernate-validator-6.0.10.Final.jar
...
querydsl-apt-4.1.4.jar
querydsl-codegen-4.1.4.jar
...

不确定此处列出哪些其他依赖项可能会对此问题感兴趣。

另外,我们不在POM中使用Spring Boot Starter Parent POM,就像它通常是通过Spring Initializr生成的一样:

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

另外,正确的用法是什么:

<java.version>10</java.version>

or 

<java.version>1.10</java.version>

最后一次提及: 在Eclipse中它说“JRE系统库[J2SE-1.5]”,我不知道它是如何出现“J2SE-1.5”,在我记忆之前是1.8。在“已安装的JRE”下的“首选项”中,位于“/ usr / lib / jvm / java-10-oracle”的位置为“java-10-oracle(默认)”。

如果我打开JRE系统库,它会对所有内容说“/ usr / lib / jvm / java-10-oracle /...”。

也许是因为“J2SE-1.5”我在Eclipse中遇到了一些Java问题,例如:

'<>' operator is not allowed for source level below 1.7

如果我导航到这个Java问题,那就是行:

...
Set<Authority> authorities = new HashSet<>();
...

谢谢!

0 个答案:

没有答案