1

私はMavenを初めて使用します。Mavenプロジェクトを作成しました。これにはスキーマのみが含まれます。私の意図は、このプロジェクトにすべての XSD を保持し、JAXB 生成クラスの jar をコンパイルして作成することです。以下は私のPOMです

<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.ads</groupId>
  <artifactId>adsSchema</artifactId>
   <packaging>jar</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>adsSchema</name>
    <pluginRepositories>  
    <pluginRepository>  
        <id>maven2-repository.dev.java.net</id>  
        <name>Java.net Repository for Maven</name>  
        <url>http://download.java.net/maven/2/</url>  
        <layout>default</layout>  
    </pluginRepository>  
    </pluginRepositories>
     <build>  
         <plugins>  
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>  
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>  
                <!-- jaxb plugin -->  
                <groupId>org.jvnet.jaxb2.maven2</groupId>  
                <artifactId>maven-jaxb2-plugin</artifactId>  
                <executions>  
                        <execution>  
                            <id>adsSchema</id>  
                            <goals>  
                                    <goal>generate</goal>  
                            </goals>  
                                <configuration>  
                                    <args>  
                                        <param>-npa</param>  
                                    </args>  
                                    <!-- the package for the generated java classes -->  
                                    <generatePackage>com.ads.beans</generatePackage>  
                                    <npa>true</npa>  
                                    <!-- include the following schemas only; by default all *.xsd files are processed -->
                                    <schemaIncludes>
                                        <schemaDirectory>src/main/resources</schemaDirectory>  
                                        <include>AuthenticateUser.xsd</include>  
                                    </schemaIncludes>  
                                    <!-- whether old output should be removed, this field should generally be set to "true" -->  
                                    <removeOldOutput>true</removeOldOutput>  
                                    <!-- generate lots of output -->  
                                    <verbose>true</verbose>  
                                </configuration>  
                        </execution>  
                </executions>  
            </plugin>  
        </plugins>  
    </build>  
     <dependencies>
     <dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-xjc</artifactId>
    <version>2.2-promoted-b65</version>
</dependency>

     <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.2-promoted-b65</version>
    </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-activation_1.1_spec</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.7</version>
        </dependency>

         <dependency>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-basics-runtime</artifactId>
            <version>0.6.4</version>
        </dependency>
        <dependency>
            <groupId>sun.jdk</groupId>
            <artifactId>tools</artifactId>
            <version>1.5.0</version>
            <scope>system</scope>
            <systemPath>C:\Program Files\Java\jdk1.5.0_22\lib\tools.jar</systemPath>
        </dependency>
    </dependencies>
  </project>

My Project Structure is 
      src
         main
             java
                  My Package(Where all Java files get created).
      target
          classes

Maven Complie を使用すると、以下のエラーが発生します。

Exception in thread "main" java.lang.Error: java.lang.reflect.InvocationTargetException
    at com.sun.tools.xjc.reader.Ring.get(Ring.java:113)
    at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.<init>(BGMBuilder.java:146)
    at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:116)
    at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:426)
    at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:175)
    at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:120)
    at org.jvnet.mjiip.v_2_2.XJC22Mojo.loadModel(XJC22Mojo.java:50)
    at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:40)
    at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:27)
    at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:314)
    at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:156)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:592)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
    at com.sun.tools.xjc.reader.Ring.get(Ring.java:102)
    ... 31 more
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
    at com.sun.tools.xjc.reader.Ring.get(Ring.java:113)
    at com.sun.tools.xjc.reader.xmlschema.BindingComponent.getClassSelector(BindingComponent.java:65)
    at com.sun.tools.xjc.reader.xmlschema.ColorBinder.<init>(ColorBinder.java:62)
    at com.sun.tools.xjc.reader.xmlschema.BindGreen.<init>(BindGreen.java:63)
    ... 36 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
    at com.sun.tools.xjc.reader.Ring.get(Ring.java:102)
    ... 39 more
Caused by: java.lang.NoClassDefFoundError: javax/activation/MimeTypeParseException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
    at java.lang.Class.getConstructor0(Class.java:2671)
    at java.lang.Class.getDeclaredConstructor(Class.java:1953)
    at com.sun.tools.xjc.reader.Ring.get(Ring.java:100)
    at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.<init>(DefaultClassBinder.java:98)
    at com.sun.tools.xjc.reader.xmlschema.ClassSelector.<init>(ClassSelector.java:214)
    ... 44 more

問題を解決するために私を助けてください。

4

4 に答える 4

1

activation.jar がありません ( Caused by: java.lang.NoClassDefFoundError: javax/activation/MimeTypeParseException)。

あなたに追加してください:

<dependency>
  <groupId>javax.activation</groupId>
  <artifactId>activation</artifactId>
  <version>1.1.1</version>
</dependency>
于 2012-10-12T06:34:07.480 に答える