2017-03-02 3 views
1

Ich versuche Profile in meinem Projekt pom.xml Datei zu verwenden, um die Bereitstellung meiner WAR-Datei auf einem bestimmten Server zu steuern. Als Beispiel habe ich ein lokales Profil und ein Entwicklungsserverprofil. Hier ist, wie ich meine Profile einrichtenMaven Tomcat deploy Plugin mit Profilen

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

Ich rufe

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

Wenn ich versuche, dies kann ich sehen, dass anstatt zu versuchen, die IP-Adresse in meiner Konfiguration 10.16.21.60, sofern die Verbindung Es versucht stattdessen, eine Verbindung zu localhost herzustellen. Ich habe beide devTomcat und localTomcat in meiner lokalen settings.xml Datei mit Benutzername und Passwort definiert.

Wenn ich die -X Option fügen Sie dann für weitere Informationen I in der Debug-Ausgabe für das Plugin sehen (Betonung hinzugefügt)

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

Es scheint nicht, dass meine Konfigurationseinstellungen eingehalten werden! Die Art, wie ich dachte, dass das funktionieren würde, ist, dass das local Profil aktiviert ist, würde es diese Konfiguration verwenden.

Ich habe auch versucht, einfach das Plugin in meinem <build> Abschnitt definiert, ohne die Profile, mit dem gleichen Effekt. Es versucht immer, eine Verbindung zu http://localhost:8080 ohne Authentifizierung herzustellen.

Es ist wahrscheinlich erwähnenswert, dass ich auch die gwt-maven-plugin für dieses Projekt verwende, und ich weiß nicht, ob dies die Tomcat-Plugin-Konfiguration stören könnte.

Antwort

0

Ok, stellt sich heraus, dass ich das falsche groupID für das Plugin verwendet habe. Es ist nicht

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

es

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

Works wie ein Weltmeister jetzt!