2017-03-02 151 views
1

我正在尝试使用我的项目pom.xml文件中的配置文件来控制我的战争文件到特定服务器的部署。举个例子,我有一个本地配置文件和一个开发服务器配置文件。这里是我有我的配置文件设置Maven Tomcat部署插件与配置文件

<profiles> 

    <profile> 
     <id>local</id> 
     <activation> 
      <activeByDefault>true</activeByDefault> 
      <property> 
       <name>target</name> 
       <value>local</value> 
      </property> 
     </activation> 
     ... 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>tomcat7-maven-plugin</artifactId> 
        <version>2.2</version> 
        <configuration> 
         <url>http://10.16.21.60:8080/manager/text</url> 
         <server>localTomcat</server> 
         <path>/</path> 
        </configuration> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 

    <profile> 
     <id>dev</id> 
     <activation> 
      <property> 
       <name>target</name> 
       <value>dev</value> 
      </property> 
     </activation> 
     ... 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>tomcat7-maven-plugin</artifactId> 
        <version>2.2</version> 
        <configuration> 
         <url>http://devserverurl:8080/manager/text</url> 
         <server>devTomcat</server> 
         <path>/</path> 
        </configuration> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 

我打电话

mvn org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy 

当我尝试这一点,我可以看到的是,而不是试图连接到我的配置10.16.21.60提供的IP地址,而是试图连接到localhost。我使用用户名和密码在本地settings.xml文件中定义了devTomcatlocalTomcat

如果我再加入-X选项更多的信息,我可以在调试输出插件看到(加上强调

 
    [DEBUG] Configuring mojo org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy from plugin realm ClassRealm[plugin>org.apache.tomcat.maven:tomcat7-maven-plugin:2.2, parent: sun.misc.Launcher$AppClassLoader[email protected]] 
    [DEBUG] Configuring mojo 'org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy' with basic configurator --> 
    [DEBUG] (f) charset = ISO-8859-1 
    [DEBUG] (f) contextFile = .... 
    [DEBUG] (f) ignorePackaging = false 
    [DEBUG] (f) mode = war 
    [DEBUG] (f) packaging = war 
    [DEBUG] (f) path = ... 
    [DEBUG] (f) update = false 
    [DEBUG] (f) url = http://localhost:8080/manager/text 
    [DEBUG] (f) version = 2.2 
    [DEBUG] (f) warFile = ... 
    [DEBUG] (f) settings = [email protected] 
    [DEBUG] -- end configuration -- 
    [INFO] Deploying war to http://localhost:8080/... 
    [DEBUG] No server specified for authentication - using defaults 

它不会出现我的配置设置正在坚持!我认为这将起作用的方式是,因为激活了local配置文件,它将使用该配置。

我也尝试过简单地在我的<build>部分定义插件,但没有配置文件,效果相同。它始终尝试连接到http://localhost:8080而无需身份验证。

可能值得注意的是,我也在为这个项目使用gwt-maven-plugin,我不知道这是否会干扰tomcat插件配置。

回答

0

好吧,事实证明我使用错误的groupID为插件。这不是

<groupId>org.codehaus.mojo</groupId> 

<groupId>org.apache.tomcat.maven</groupId> 

作品像现在一个冠军!