嘿,我写这篇文章是因为我花了一些时间尝试将 Jackson ObjectMapper 配置为在我的设备上没有 @JsonCreator
和 @JsonProperty
注释的情况下工作DTO。我想要实现的结果是能够在 intellij 和带有 maven 的控制台中运行 Spock 的测试(groovy)。
最佳答案
此问题已解决:https://youtrack.jetbrains.com/issue/IDEA-125737 intellij 自动获取以下 Maven 配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-parameters</compilerArgument>
<testCompilerArgument>-parameters</testCompilerArgument>
</configuration>
</plugin>
此外,如果您想使用 Spock 在 groovy 中进行测试,您需要以下插件配置:
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>${gmavenplus-plugin.version}</version>
<configuration>
<parameters>true</parameters>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
加上附加信息:
- 在我写这篇文章时,只有一个版本的 groovy 编译器适合我:2.5.0-alpha-1
- 我使用的maven-compiler-plugin版本是3.7.0。 3.1版本根本不起作用。我没有尝试其他的。
我希望这可以节省一些人的时间:)
关于java - 如何配置 maven 和 intellij 以包含 groovy 和 java 的参数编译器标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51634815/