0

作成したすべてのクラスでtoString()を生成するcxfプラグインを追加しました。メソッドが追加され、正常にコンパイルされますが、mavenパッケージ化されたjarを別のプロジェクトのビルドパスに追加し、オブジェクトをtoStringに追加すると、次のようになります。

java.lang.NoClassDefFoundError: org/apache/cxf/xjc/runtime/JAXBToStringStyle
    at com.resx.services.Profile.toString(Profile.java:420)
    at java.lang.String.valueOf(String.java:2826)
    ...
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.xjc.runtime.JAXBToStringStyle

私のpomが間違って設定されていると思いますが、よくわかりません。これがpom.xmlです:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>com.trx</groupId>
  <artifactId>resxWebservices</artifactId>
  <version>10.4.1</version>

  <name>resxWebservices</name>
  <packaging>jar</packaging>

  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-codegen-plugin</artifactId>
        <version>2.6.0</version>
        <executions>
          <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
              <sourceRoot>src</sourceRoot>
              <wsdlOptions>
                <wsdlOption>
                  <wsdl>./resxWebservices.wsdl</wsdl>
                  <extraargs>
                    <extraarg>-xjc-Xts</extraarg>
                  </extraargs>
                </wsdlOption>
              </wsdlOptions>
            </configuration>
            <goals>
              <goal>wsdl2java</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.apache.cxf.xjc-utils</groupId>
            <artifactId>cxf-xjc-runtime</artifactId>
            <version>2.6.0</version>
          </dependency>
          <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
          </dependency>
          <dependency>
            <groupId>org.apache.cxf.xjcplugins</groupId>
            <artifactId>cxf-xjc-ts</artifactId>
            <version>2.6.0</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <verbose>true</verbose>
          <fork>true</fork>
          <executable>${JAVA_HOME}/bin/javac</executable>
          <compilerVersion>1.6</compilerVersion>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.apache.cxf.xjc-utils</groupId>
      <artifactId>cxf-xjc-runtime</artifactId>
      <version>2.6.0</version>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.6</version>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf.xjcplugins</groupId>
      <artifactId>cxf-xjc-ts</artifactId>
      <version>2.6.0</version>
    </dependency>
  </dependencies>
</project>

私も追加してみました

<scope>compile</scope>

同じ問題の依存関係に。

4

1 に答える 1

2

他のプロジェクトを実行するときも、クラスパスでcxfjarが使用可能であることを確認する必要があります。

最初のプロジェクトを2番目のプロジェクトの依存関係としてリストし、適切な依存関係が推移的に引き継がれるようにする必要があります(jar自体をビルドパスに追加するだけではありません)。

または、cxf jarも含む最初のプロジェクトの依存関係のあるjarを作成し、それを2番目のプロジェクトのduild/runtimeクラスパスに追加します。

于 2012-06-06T19:31:24.403 に答える