3 回答

TA貢獻1851條經驗 獲得超4個贊
我用以下配置解決了同樣的問題。
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<fork>true</fork>
<compilerArgs>
<compilerArg>-J-Duser.language=en</compilerArg>
<compilerArg>-J-Duser.country=US</compilerArg>
<compilerArg>-J-Dfile.encoding=UTF-8</compilerArg>
</compilerArgs>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate.version}</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</plugin>

TA貢獻1802條經驗 獲得超10個贊
2023 年 3 月更新:
在您的項目中添加包含內容的.mvn/jvm.config文件-Duser.country=US -Duser.language=en
似乎會更改 Maven 的語言環境,這似乎是更好的方法。
2023 年 2 月更新:
經過一些調試,下面是我對這個問題的發現:
即使我的實體(編碼方式)沒有問題,JpaMetaModelGen 的 StringUtils 類方法使用 toUpperCase() 方法,該方法使用 JVM 的默認 Locale 進行大寫操作。以下是一些關于 upperCase 方法的文檔:
此方法對區域設置敏感,如果用于旨在獨立解釋區域設置的字符串,可能會產生意外結果。示例是編程語言標識符、協議密鑰和 HTML 標記。例如,土耳其語言環境中的“title”.toUpperCase() 返回“T\u0130TLE”,其中“\u0130”是帶點的拉丁文大寫字母 I。要獲得不區分語言環境的字符串的正確結果,請使用 toUpperCase(Locale.ROOT)。
似乎我需要將我的 JVM 區域設置更改為英語(通常當您調用 java 命令時,您需要添加這些 jvm args:-Duser.country=US -Duser.language=en)以解決此問題,但添加這些to mvn 命令對我不起作用,所以在 IDEA 中我這樣做了,它似乎起作用了。

TA貢獻1853條經驗 獲得超6個贊
我有同樣的問題。我的問題已通過以下插件解決
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-proc:none</compilerArgument>
<encoding>UTF-8</encoding>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<compilerArguments>-AaddGeneratedAnnotation=false</compilerArguments> <!-- suppress java.annotation -->
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
<outputDirectory>generated</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
添加回答
舉報