Hibernate JPA 2 Metamodel Generator Turkish Char问题
Hibernate JPA 2 Metamodel Generator Turkish Char problem
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>6.0.0.Alpha2</version>
</dependency>
当我将 hibernate-jpamodelgen 依赖项添加到项目时。在编译过程之前一切正常。我可以在目标文件夹下看到生成的元模型 类。但是由于我的系统默认值(与我的操作系统相关),元模型 类 上的字段名称常量转换错误。
public static final String TRANST�ME = "transtime";
public static final String NOTE = "note";
public static final String �SACT�VE = "isactive";
-
[ERROR] /C:/Users/*/IdeaProjects/*/target/generated-sources/annotations/*/model/acc/InvtypeView_.java:[20,37] illegal character: '\ufffd'
这会导致编译错误。当我分析代码生成过程时,我可以看到 org.hibernate.jpamodelgen.util.StringUtil 类' getUpperUnderscoreCaseFromLowerCamelCase 方法导致了这一点。
public static String getUpperUnderscoreCaseFromLowerCamelCase(String lowerCamelCaseString){
return lowerCamelCaseString.replaceAll("(.)(\p{Upper})", "_").toUpperCase();
}
toUpperCase 方法应该有参数 Locale.ROOT。
我在 Hibernate issue tracker system 上创建了一个问题。
任何快速 solution/workaround 都很好。
我已经通过以下配置解决了同样的问题。
<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>
我遇到了同样的问题。我的问题已通过以下插件解决
<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>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>6.0.0.Alpha2</version>
</dependency>
当我将 hibernate-jpamodelgen 依赖项添加到项目时。在编译过程之前一切正常。我可以在目标文件夹下看到生成的元模型 类。但是由于我的系统默认值(与我的操作系统相关),元模型 类 上的字段名称常量转换错误。
public static final String TRANST�ME = "transtime";
public static final String NOTE = "note";
public static final String �SACT�VE = "isactive";
-
[ERROR] /C:/Users/*/IdeaProjects/*/target/generated-sources/annotations/*/model/acc/InvtypeView_.java:[20,37] illegal character: '\ufffd'
这会导致编译错误。当我分析代码生成过程时,我可以看到 org.hibernate.jpamodelgen.util.StringUtil 类' getUpperUnderscoreCaseFromLowerCamelCase 方法导致了这一点。
public static String getUpperUnderscoreCaseFromLowerCamelCase(String lowerCamelCaseString){
return lowerCamelCaseString.replaceAll("(.)(\p{Upper})", "_").toUpperCase();
}
toUpperCase 方法应该有参数 Locale.ROOT。
我在 Hibernate issue tracker system 上创建了一个问题。
任何快速 solution/workaround 都很好。
我已经通过以下配置解决了同样的问题。
<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>
我遇到了同样的问题。我的问题已通过以下插件解决
<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>