简体   繁体   English

删除,复制和修改pom.xml文件

[英]Delete, copy and modify a pom.xml file

My pom.xml file with three different plugins: the first generates .java from .xsd, the second changes the .java from folder and the third deletes the originals .java 我的pom.xml文件具有三个不同的插件:第一个从.xsd生成.java,第二个从文件夹中更改.java,第三个删除原始的.java

  ...
  <build>
        <plugins>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.12.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                     <execution>
                        <id>copy-resources</id>
                        <phase>validate</phase>
                        <goals>
                           <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                           <outputDirectory>${basedir}/src/main/java/pt/thales/attracktive/communication/pojo</outputDirectory>
                           <resources>          
                                <resource>
                                    <directory>${basedir}/target/generated-sources/xjc/uk/org/siri/siri</directory>
                                    <filtering>true</filtering>
                                    <includes>
                                        <include>*.java</include>
                                    </includes>
                                </resource>
                           </resources>              
                        </configuration>            
                    </execution>
                 </executions>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                  <filesets>
                    <fileset>
                      <directory>${basedir}/target/generated-sources/xjc/uk/org/siri/siri</directory>
                      <includes>
                        <include>**/*.java</include>
                      </includes>
                      <followSymlinks>false</followSymlinks>
                    </fileset>
                  </filesets>
                </configuration>
            </plugin>
        </plugins>
  </build>
</project>

Questions: 问题:

  1. Can I have a delete plugin and a change folder plugin? 我可以有一个删除插件和一个更改文件夹插件吗? From what I tested I can't because the delete plugin is "stronger" and don't let the change folder plugin to act 根据我的测试,我不能,因为删除插件“更强”,并且不要让更改文件夹插件起作用
  2. When I change folder the package name also changes, is it possible to update it? 当我更改文件夹时,软件包名称也会更改,是否可以对其进行更新?
  3. Why do I get this ERROR with this two .xsd 为什么我用这两个.xsd收到此错误

SubscriptionRequest.xsd: SubscriptionRequest.xsd:

<?xml version="1.0" encoding="utf-8"?>
    <xs:schema xmlns:tns="http://www.siri.org.uk/siri" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.siri.org.uk/siri" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="RequestorRef" type="xs:string" />
      <xs:element name="MessageIdentifier" type="xs:string" />
      <xs:element name="ConsumerAddress" type="xs:string" />
      <xs:element name="SubscriberRef" type="xs:string" />
      <xs:element name="SubscriptionIdentifier" type="xs:unsignedByte" />
      <xs:element name="InitialTerminationTime" type="xs:dateTime" />
    </xs:schema>

and TerminateSubscriptionRequest.xsd: 和TerminateSubscriptionRequest.xsd:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://www.siri.org.uk/siri" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.siri.org.uk/siri" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="RequestTimestamp" type="xs:dateTime" />
  <xs:element name="RequestorRef" type="xs:string" />
  <xs:element name="SubscriberRef" type="xs:string" />
  <xs:element name="SubscriptionRef" type="xs:unsignedByte" />
</xs:schema>~

Result: 结果:

[ERROR] Error while parsing schema(s).Location [ file:/C:/Users/rapha/Desktop/Thales/attracktive-master/thales.attracktive.communication/attracktive.communication/src/main/resources/TerminateSubscriptionRequest.xsd{4,54}]. [错误]解析模式时出错。位置[文件:/ C:/Users/rapha/Desktop/Thales/attracktive-master/thales.attracktive.communication/attracktive.communication/src/main/resources/TerminateSubscriptionRequest.xsd {4,54}]。 org.xml.sax.SAXParseException; org.xml.sax.SAXParseException; systemId: file:/C:/Users/rapha/Desktop/Thales/attracktive-master/thales.attracktive.communication/attracktive.communication/src/main/resources/TerminateSubscriptionRequest.xsd; systemId:文件:/ C:/Users/rapha/Desktop/Thales/attracktive-master/thales.attracktive.communication/attracktive.communication/src/main/resources/TerminateSubscriptionRequest.xsd; lineNumber: 4; lineNumber:4; columnNumber: 54; columnNumber:54; 'RequestorRef' is already defined 'RequestorRef'已经定义

I tried different thigs but it didn't result probably I'm missing something. 我尝试了不同的尝试,但未找到可能是我缺少了一些东西。 Thanks for the lecture and if you can help me please 感谢您的演讲,如果您能帮助我,请

To change the package, you can use the generatePackage option for the jaxb2 plugin, as described in the plug-ins docs . 要更改软件包,可以对jaxb2插件使用generatePackage选项,如插件docs中所述 If you require something more powerful (like putting different schemas in different packages), you'll need to use jaxb2 bindings files as described in the jaxb docs . 如果您需要更强大的功能(例如将不同的架构放入不同的程序包中),则需要使用jaxb docs中所述的jaxb2绑定文件。

The duplicate element error is due to both of your files declaring the RequestorRef element in the same namespace. 重复元素错误是由于两个文件都在同一名称空间中声明了RequestorRef元素。 You can fix this by either: 您可以通过以下任一方法解决此问题:

  • Merging the two files, which seems to be the best option since the namespace is the same 合并两个文件,这似乎是最好的选择,因为名称空间相同
  • changing the namespace in one of the files so they don't clash. 更改其中一个文件的名称空间,以免它们冲突。 This would make sense if the duplicated elements are actually different elements 如果重复的元素实际上是不同的元素,这将很有意义

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM