简体   繁体   English

maven如何将xml文件配置为pom.xml

[英]maven how to configuration xml file into pom.xml

when running at cmd normally command is java -jar xxx.jar param1. 在cmd上正常运行时,命令为java -jar xxx.jar param1。 my command is java -jar n2n-adaptor-cimbr-news-pdf-jar-with-dependencies.jar hostserver.xml 我的命令是java -jar n2n-adaptor-cimbr-news-pdf-jar-with-dependencies.jar hostserver.xml

how to conficuration hostserver.xml at pom.xml? 如何在pom.xml上充斥hostserver.xml? so tat no need run param at cmd. 因此,tat无需在cmd上运行param。

<modelVersion>4.0.0</modelVersion>
<groupId>n2n</groupId>
<artifactId>n2n-adaptor-cimbr-news-pdf</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
    <java.version>1.7</java.version>
    <main.class>com.n2n.newsPDF.MainNewsCIMBRHostServer</main.class>
</properties>
<build>
    <finalName>${project.artifactId}</finalName>
    <pluginManagement>
        <plugins>
            <!-- We specify the Maven compiler plugin as we need to set it to Java 
                1.8 -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>


    <plugins>
        <!-- Maven Assembly Plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4.1</version>
            <configuration>
                <!-- get all project dependencies -->
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <!-- MainClass in mainfest make a executable jar -->
                <archive>
                    <manifest>
                        <mainClass>${main.class}</mainClass>
                    </manifest>
                </archive>
                <suiteXmlFiles>
                <suiteXmlFile>${project.build.directory}/resources/hostserver2.xml</suiteXmlFile>
              </suiteXmlFiles>


            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <!-- bind to the packaging phase -->
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

    </plugins>
    <resources>
    <resource>
        <filtering>true</filtering>
        <directory>src/main/resources</directory>
        <includes>
             <include>hostserver2.xml</include>
         </includes>
    </resource>

</resources>
</build>

after i make configuration it can't running when i run java -jar n2n-adaptor-cimbr-news-pdf-jar-with-dependencies.jar. 我进行配置后,当我运行java -jar n2n-adaptor-cimbr-news-pdf-jar-with-dependencies.jar时,它将无法运行。

please kindly advice. 请指教。

Thanks Sharon 谢谢沙龙

This is a problem you need to solve within Java, not Maven. 这是您需要在Java(而非Maven)中解决的问题。 You define the parameters of your Java Main class. 您定义Java Main类的参数。 If you want to replace command line parameters with resources, this is the place to go. 如果要用资源替换命令行参数,这是一个好去处。

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

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