Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven-xmlbean-set类路径_Java_Xml_Maven 3 - Fatal编程技术网

Java Maven-xmlbean-set类路径

Java Maven-xmlbean-set类路径,java,xml,maven-3,Java,Xml,Maven 3,我需要为maven xmlbean插件设置类路径,因为xsd依赖于我的2个java程序,我不希望将其打包为jar并将其添加到依赖项中 注意:我不希望使用maven ant插件来完成上述任务 maven xml插件引发的实际错误: error: cvc-complex-type.2.4a: Expected elements 'namespace@http://xml.apache.org/xmlbeans/2004/02/xbean/config qname@http://xml.

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

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

maven xml插件引发的实际错误:

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

    <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>

4.0.0
mygroup
我的人工制品
V1
罐子
我的人工制品
src
org.codehaus.mojo
xmlbeans maven插件
2.3.3
generateEbpacObjectMapJar
生成源
xmlbeans
真的
50米
80米
src/xsddir
src/myconfig.xsdconfig
目标/生成/源
真的
org.apache.xmlbeans
xmlbeans
2.4.0
net.sf.saxon
撒克逊人
8.7
org.apache.xmlbeans
xmlbeans xpath
2.4.0
org.apache.xmlbeans
xmlbeans xmlpublic
2.4.0
org.apache.xmlbeans
xmlbeans qname
2.4.0
org.apache.xbean
xbean
2.5

xsd配置如下:

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>
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“>
com.ImplClassHandler
您可以查看
,如果
标记在Maven depency中使用,JAR将在编译时从.m2目录中提供;但不包括在包装中。

但是,您需要确保库jar应该在JVM的类路径中的某个位置可用。

如何确保库jar在JVM的类路径中,并清楚地解释了我的问题请发布pom.xml