首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven xml bean - set类路径

Maven xml bean - set类路径
EN

Stack Overflow用户
提问于 2013-09-26 17:50:26
回答 1查看 543关注 0票数 0

我需要为maven xmlbean插件设置类路径,因为xsd依赖于我的2个java程序,我不希望将其打包为jar,并将其添加到依赖项中。

注意:我不希望使用maven ant插件来完成上述任务。

maven-xml插件抛出的实际错误:

代码语言:javascript
复制
error: cvc-complex-type.2.4a: Expected elements       'namespace@http://xml.apache.org/xmlbeans/2004/02/xbean/config  qname@http://xml.apache.org/xmlbeans/2004/02/xbean/config  extension@http://xml.apache.org/xmlbeans/2004/02/xbean/config'  instead of   'usertype@http://xml.apache.org/xmlbeans/2004/02/xbean/config'  here in element config @http://xml.apache.org/xmlbeans/2004/02/xbean/config

由于我在xmlconfig中使用了2个usertype,并且我是位用户,所以maven-xmlplugin无法定位这些类。我甚至尝试打包这些类并添加依赖项,尽管失败了。

pom.xml

代码语言:javascript
复制
    <project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<groupId>mygroup</groupId>
<artifactId>myartifacts</artifactId>
<version>V1</version>

<packaging>jar</packaging>
<name>myartifacts</name>

<build>     
    <sourceDirectory>src</sourceDirectory>
    <plugins>           
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>xmlbeans-maven-plugin</artifactId>
            <version>2.3.3</version>
            <executions>
                <execution>
                    <id>generateEbpacObjectMapJar</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xmlbeans</goal>
                    </goals>
                </execution>
            </executions> 
            <inherited>true</inherited>
            <configuration>
                <memoryInitialSize>50m</memoryInitialSize>
                <memoryMaximumSize>80m</memoryMaximumSize>                  
                <schemaDirectory>src/xsddir</schemaDirectory>
                <xmlConfigs>
                    <xmlConfig implementation="java.io.File">src/myconfig.xsdconfig</xmlConfig>
                </xmlConfigs>
                <sourceGenerationDirectory>target/generated/JARSources</sourceGenerationDirectory>
                <debug>true</debug>
            </configuration>
        </plugin>
    </plugins>
</build>    
<dependencies>
    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>net.sf.saxon</groupId>
        <artifactId>saxon</artifactId>
        <version>8.7</version>
    </dependency>
    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans-xpath</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans-xmlpublic</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans-qname</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.xbean</groupId>
        <artifactId>xbean</artifactId>
        <version>2.5</version>
    </dependency>
</dependencies>

xsd配置如下:

代码语言:javascript
复制
xb:config 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config" 
    xmlns:ebpac="http://bct.com/platform/factory"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://xml.apache.org/xmlbeans/2004/02/xbean/config xmlconfig.xsd">
<xb:usertype name="cl:myClass" javaname="java.lang.Class">
    <xb:staticHandler>com.ImplClassHandler</xb:staticHandler>
</xb:usertype>
EN

回答 1

Stack Overflow用户

发布于 2013-09-26 18:35:24

您可以在Maven depedency中查看<scope>provided</scope>标记的使用情况,jars将在编译时从您的.m2目录中获得;但不包括在打包中。但是,您需要确保库jar应该在JVM的类路径中的某个位置可用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19024941

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档