Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.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构建中的tomcat和jar并行执行_Java_Maven_Tomcat_Jar - Fatal编程技术网

Java maven构建中的tomcat和jar并行执行

Java maven构建中的tomcat和jar并行执行,java,maven,tomcat,jar,Java,Maven,Tomcat,Jar,我有一个maven构建,它在运行配置文件上使用tomcat7 maven插件运行我的应用程序。 我想在tomcat执行的同时运行一个jar(例如使用maven exec插件)。这个jar是我用于本地开发的ldap服务 到目前为止,我已经能够在单独的maven执行(其他pom)中运行这个jar: org.codehaus.mojo execmaven插件 1.4.0 跑 JAVA x、 y.z.ldap.LdapServerRunner 本地服务器 50000 src/main/resource

我有一个maven构建,它在运行配置文件上使用tomcat7 maven插件运行我的应用程序。 我想在tomcat执行的同时运行一个jar(例如使用maven exec插件)。这个jar是我用于本地开发的ldap服务

到目前为止,我已经能够在单独的maven执行(其他pom)中运行这个jar:


org.codehaus.mojo
execmaven插件
1.4.0
跑
JAVA
x、 y.z.ldap.LdapServerRunner
本地服务器
50000
src/main/resources/ldap-dev.ldif
真的
真的
J
整数解
x、 x.x快照
如果我将其添加到maven依赖插件的同一pom中,maven将在开始tomcat执行之前等待main结束。 我想知道是否可以在本地tomcat执行的同一时间运行我的jar(x.y.z.ldap.LdapServerRunner)。

我改变了策略: 我没有完全尝试让一个单独的jar执行并行工作(并处理所有相关问题),而是让我的jar成为一个war(在特定的maven配置文件中):

  • 我创建了一个简单的类,实现了javax.servlet.ServletContextListener,我在其中编写了服务器启动和停止的contextInitializedcontextDestroyed方法

  • 我在我的项目(src/main/webapp/web-INF/web.xml)中放了一个简单的web.xml,其中包含:

  • 我改变了策略: 我没有完全尝试让一个单独的jar执行并行工作(并处理所有相关问题),而是让我的jar成为一个war(在特定的maven配置文件中):

    • 我创建了一个简单的类,实现了javax.servlet.ServletContextListener,我在其中编写了服务器启动和停止的contextInitializedcontextDestroyed方法

    • 我在我的项目(src/main/webapp/web-INF/web.xml)中放了一个简单的web.xml,其中包含:


    • 你试过了吗?没有,我去看看。谢谢。你试过了吗?没有,我去看看。谢谢
      <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>1.4.0</version>
          <executions>
              <execution>
                  <phase>run</phase>
                  <goals>
                      <goal>java</goal>
                  </goals>
                  <configuration>
                      <mainClass>x.y.z.ldap.LdapServerRunner</mainClass>
                      <arguments>
                          <argument>localhost</argument>
                          <argument>50000</argument>
                          <argument>src/main/resources/ldap-dev.ldif</argument>
                      </arguments>
                      <includePluginDependencies>true</includePluginDependencies>
                      <includeProjectDependencies>true</includeProjectDependencies>
                  </configuration>
              </execution>
          </executions>
          <dependencies>
              <dependency>
                  <artifactId>j</artifactId>
                  <groupId>x.y.z</groupId>
                  <version>x.x.x-SNAPSHOT</version>
              </dependency>
          </dependencies>
      </plugin>
      
       <listener>
           <listener-class>x.y.z.EmbeddedLdapListener</listener-class>
       </listener>
      
       <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
             <artifactId>tomcat7-maven-plugin</artifactId>
             <webapps>
                <webapp>
                  <groupId>x.y.z</groupId>
                  <artifactId>myapp</artifactId>
                  <version>1.0.0-SNAPSHOT</version>
                  <type>war</type>
                  <asWebapp>true</asWebapp>
                  <contextPath>/myapp</contextPath>
             </webapp>
             <webapp>
               <groupId>x.y.z</groupId>
               <artifactId>myldapembedded</artifactId>
               <version>1.0.0-SNAPSHOT</version>
               <type>war</type>
               <asWebapp>true</asWebapp>
               <contextPath>/ldap</contextPath>
            </webapp>
            ...
      
            <plugin>
               <groupId>org.apache.tomcat.maven</groupId>
               <artifactId>tomcat7-maven-plugin</artifactId>
               ...
               <configuration>
                  <systemProperties>
                  <myproperty>myvalue</myproperty>
      
             System.getProperty("myproperty", mydefaultValue)