将我们的应用程序更新到 Spring Boot 3.2.5 和 Spring Framework 6.1.6。我们收到以下错误。
ERROR c.a.s.t.c.e.ControllerExceptionHandler - java.lang.IllegalArgumentException: Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.
java.lang.IllegalArgumentException: Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.
ERROR c.a.s.t.c.e.ControllerExceptionHandler - java.lang.IllegalArgumentException: Null key returned for cache operation caches=[cacheExample] | key='#cacheKey' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='true']. If you are using named parameters, ensure that the compiler uses the '-parameters' flag.
java.lang.IllegalArgumentException: Null key returned for cache operation caches=[cacheExample] | key='#cacheKey' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='true']. If you are using named parameters, ensure that the compiler uses the '-parameters' flag.
它接缝,它要求使用“-parameters”标志编译(java)代码。因此,我按照 https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#parameter-name-retention:
上的说明进行操作我已添加:
tasks.withType(JavaCompile).configureEach {
options.compilerArgs.add("-parameters")
}
即使我尝试添加线程中提到的以下内容:https://github.com/spring-projects/spring-framework/issues/31729
tasks.withType(JavaCompile) {
configure(options) {
options.compilerArgs << '-parameters'
}
}
没有什么对我有用。但是,是的,添加像
key="#p0"
这样的参数索引对我来说很有效。实际上,我想使用参数名称而不是参数索引。
我使用了以下配置/工具:
您能帮我解决这个问题吗?
这对我有用:
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.compilerArgs.add("-parameters")
}