3

Maven 依存関係を使用して、組み込みの tomcat を Web アプリケーションに追加しています。正常に動作しますが、webapp がこの systemProperties を使用できるように、組み込みの tomcat に systemProperties を追加する必要があります。

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>tomcat-run</id>
                    <goals>
                        <goal>exec-war-only</goal>
                    </goals>
                    <phase>package</phase>
                    <configuration>
                        <path>/html5</path>
                        <enableNaming>true</enableNaming>
                        <finalName>html5.jar</finalName>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

このようにシステム プロパティを追加しようとしましたが、うまくいきませんでした。追加しました

<build>
    <plugins>
        <plugin>
            <configuration>
                <systemProperties>
                    <dashboard.oracle.host>1.1.1.1</dashboard.oracle.host>
                    <dashboard.oracle.port>1521</dashboard.oracle.port>
                    <dashboard.oracle.sid>orcl</dashboard.oracle.sid>
                    <dashboard.oracle.url>
                        jdbc:oracle:thin:@${dashboard.oracle.host}:${dashboard.oracle.port}:${dashboard.oracle.sid}
                    </dashboard.oracle.url>
                    <dashboard.oracle.username>username</dashboard.oracle.username>
                    <dashboard.oracle.password>password</dashboard.oracle.password>
                </systemProperties>
            </configuration>
            ...
        </plugin>
    </plugins>
</build>
4

2 に答える 2

6

一般に、システム プロパティを tomcat プラグインに追加した方法は正しいです。

<plugin>
  <groupId>org.apache.tomcat.maven</groupId>
  <artifactId>tomcat6-maven-plugin</artifactId>
  <version>2.1</version>
  <configuration>
    <systemProperties>
      <example.value.1>alpha</example.value.1>
      <example.value.2>beta</example.value.2>
    </systemProperties>
  </configuration>
</plugin>

Apache Docuから取得。

于 2015-03-26T10:23:59.383 に答える
2

Maven プラグインのシステム プロパティは、tomcat7:run mojo を実行する場合にのみ使用されます。システム プロパティを実行可能な war (jar) に渡すには、コマンド ラインで次のように実行する必要があります: java -DsysProp1=value -DsysProp2=値 -jar exec-war.jar

于 2015-06-18T15:58:07.617 に答える