gpt4 book ai didi

java - 无法访问类的绑定(bind)信息

转载 作者:行者123 更新时间:2023-11-29 08:49:20 24 4
gpt4 key购买 nike

我知道这个问题已经被问了一遍又一遍,它始终是 Eclipse Maven JIXB 问题。我认为它从未得到解决。

当我尝试测试我的代码时,出现以下错误

Unable to access binding information for class com.generated.xml.addbooking.Request
Make sure the binding has been compiled
java.lang.NoSuchFieldException: JiBX_bindingList
at java.lang.Class.getDeclaredField(Class.java:1882)
at org.jibx.runtime.BindingDirectory.getBindingList(BindingDirectory.java:68)

现在我已经生成了 POJO 并使用以下 POM 生成了一个 binding.xml 文件。

<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.5</version>
<executions>
<execution>
<id>schemata-a</id>
<goals>
<goal>schema-codegen</goal>
</goals>
<configuration>
<schemaLocation>src/main/resources/schemas</schemaLocation>
<includeSchemas>
<includeSchema>AddBookingRequest.xsd</includeSchema>
</includeSchemas>
<schemaBindingDirectory>src/main/java</schemaBindingDirectory>
<includeSchemaBindings>
<includeSchemaBindings>binding.xml</includeSchemaBindings>
</includeSchemaBindings>
<options>
<package>com.generated.xml.addbooking</package>
</options>
</configuration>
</execution>
<execution>
<id>schemata-b</id>
<goals>
<goal>schema-codegen</goal>
</goals>
<configuration>
<schemaLocation>src/main/resources/schemas</schemaLocation>
<includeSchemas>
<includeSchema>SearchHotelPriceRequest.xsd</includeSchema>
</includeSchemas>
<schemaBindingDirectory>src/main/java</schemaBindingDirectory>
<includeSchemaBindings>
<includeSchemaBindings>binding.xml</includeSchemaBindings>
</includeSchemaBindings>
<options>
<package>com.generated.xml.searchhotel</package>
</options>
</configuration>
</execution>
<execution>
<id>compile-binding</id>
<goals>
<goal>bind</goal>
</goals>
<configuration>
<schemaBindingDirectory>src/main/java</schemaBindingDirectory>
<includes>
<include>binding.xml</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>

如您所见,生成了 POJO,生成了 binding.xml,但由于某种原因绑定(bind)没有运行?

最佳答案

由于某些原因,需要添加另一个指向 1.5 或更高版本的插件,maven 2 插件正在针对 1.3 进行编译。导致使用泛型的绑定(bind)问题。

我在我的插件中添加了以下内容

            <plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument></compilerArgument>
</configuration>
</plugin>

关于java - 无法访问类的绑定(bind)信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23538712/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com