我一直在寻找几天,与可能发生的冲突或我在将 spring 引导放入项目时所做的错误配置相关的问题。当代码中不存在 (@Validated) 时,所有依赖项通常都会被注入 (@Autowired),因此它被插入,一切都停止被 spring 注入。gradle.propertiesSPRING_BOOT_VERSION=2.0.3.RELEASESPRING_CLOUD_VERSION=Finchley.RELEASE我试过这个版本:SPRING_BOOT_VERSION=2.1.0.M2依赖 build.gradlebuildscript { ext { springBootVersion = SPRING_BOOT_VERSION springCloudVersion = SPRING_CLOUD_VERSION } repositories { jcenter() mavenLocal() mavenCentral() maven { url 'https://plugins.gradle.org/m2/' } maven { url "https://repo.spring.io/snapshot" } maven { url "https://repo.spring.io/milestone" } } dependencies { classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}", "org.owasp:dependency-check-gradle:3.2.1" }}dependencies { compile "org.springframework.boot:spring-boot-starter-actuator", "org.springframework.boot:spring-boot-starter-webflux", "org.springframework.boot:spring-boot-starter-validation", "org.springframework.boot:spring-boot-starter-logging", "org.springframework.boot:spring-boot-starter-jetty", "org.springframework.boot:spring-boot-starter-cache", "org.springframework.boot:spring-boot-starter-jdbc", "org.springframework.boot:spring-boot-starter-web", "org.springframework.boot:spring-boot-starter-aop", "org.springframework:spring-context", "io.springfox:springfox-swagger2:2.9.0", "io.springfox:springfox-swagger-ui:2.9.0" compile "org.eclipse.jetty:jetty-alpn-conscrypt-server", "org.eclipse.jetty.http2:http2-server", "org.owasp:dependency-check-gradle:3.2.1", "org.codehaus.groovy:groovy-all:2.4.15", "org.liquibase:liquibase-core:3.6.1" compileOnly "org.projectlombok:lombok:1.18.0" runtime "mysql:mysql-connector-java:5.1.34"}
1 回答
郎朗坤
TA贡献1921条经验 获得超9个赞
我明白,通过定义一个方法final,类设计者承诺这个方法将始终如描述或暗示的那样工作。但是验证需要创建部分自定义,只有在没有最终.
变化自:
public final ResponseEntity<Response> createUser(@RequestHeader("token") final String token, @RequestBody final Request request) {
return createUser.execute( ... ); // createUser is null
}
为了
public ResponseEntity<Response> createUser(@RequestHeader("token") final String token, @RequestBody final Request request) {
return createUser.execute( ... ); // createUser is null
}
添加回答
举报
0/150
提交
取消