3 回答

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

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超6個(gè)贊
我有同樣的問題。我的問題已通過以下插件解決
<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>
添加回答
舉報(bào)