Bir java sınıfından erişilebilen bir sistem özelliği ayarlamak maven içinde mümkün mü?Bir maven profilinde bir sistem değişkeninin ayarlanması
Bunun mümkün olduğunu düşündüğümde, eminfire eklentisi içinde (here); Ben, ben zaten bir maven profili argüman olarak eşya veya dev geçirerek çalışıyorum çevreye ele almak istiyorum Ancak
String param = System.getProperty("my_parameter1");
<configuration>
<systemPropertyVariables>
<my_property1>${my_property1}</my_property1>
</systemPropertyVariables>
</configuration>
- bu ya bu kodda ele almak için bir türlü mümkün aradığım bir değişkeni ayarlamaktan ve sonra system.getProperty veya başka bir yoldan arama yapmaktan?
Teşekkür
Aşağıdaki yapılandırma (fark <systemProperties>
) ile exec-maven-plugin
kontrol etmelidir
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>core</groupId>
<artifactId>core</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<parallel>methods</parallel>
<threadCount>10</threadCount>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>resources</directory>
<includes>
<include>**/*.png</include>
</includes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.facebook4j</groupId>
<artifactId>facebook4j-core</artifactId>
<version>[2.0,)</version>
</dependency>
<dependency>
<groupId>com.relayrides</groupId>
<artifactId>pushy</artifactId>
<version>0.3</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.threewks.thundr</groupId>
<artifactId>thundr-mailgun</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>DEV</id>
<properties>
<swifte.url>jdbc:mariadb://ip:3306/swifte?autoReconnect=true</swifte.url>
<swifte.username>user</swifte.username>
<swifte.password>pass</swifte.password>
</properties>
<build>
<resources>
<resource>
<directory>resources</directory>
<includes>
<include>JavaPNSDev.p12</include>
</includes>
</resource>
</resources>
</build>
</profile>
<profile>
<id>PROD</id>
<properties>
<swifte.url>jdbc:mariadb://ip:3306/swifte?autoReconnect=true</swifte.url>
<swifte.username>username</swifte.username>
<swifte.password>pass</swifte.password>
</properties>
<build>
<resources>
<resource>
<directory>resources</directory>
<includes>
<include>JavaPNSProd.p12</include>
</includes>
</resource>
</resources>
</build>
</profile>
</profiles>
</project>
yüzden ben şu anda olmak maven-derleyici-eklenti kullanmak için karşı exec maven eklenti kullanmak isteyeyim yönetim kolaylığı özelliklerine yardımcı olacak bazı diğer useful goals ile birlikte
set-system-properties
amacı var? – Biscuit128Hayır, birlikte gidebilirler. Exec eklentisi, programın başlatılmasından sadece sorumludur. Derleyici eklentisi bunu yapmaz. –
Eğer bir soru sorarsanız tamam mı? Şu anda maven pom dosyasımdaki profile dayanarak bazı özelliklerde değerler ayarlıyorum. Bu sistem özelliğini profilde ayarlamak mümkün mü? çünkü gerçekten, sadece dev ve prod için bir pom dosyası ve onu ayarlamanız gereken profilde var. Şimdi benim pompamı göndereceğim – Biscuit128