這是一個簡單的服務應用程序,它創建war文件並將其部署到CAT應用程序中。 1.使用Maven的配置文件,WAR文件生成器使用代碼:如何創建引用質量和生產系統數據源的war文件,使用maven配置文件?
-1.1.Development environment @ my laptop, mvn <package> -P development
-1.2.Quality environment @ my laptop, mvn <package> -P quality
-1.3.Production environment @ production server, mvn <package> -P production
的pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bosch.bgn</groupId>
<artifactId>newsbox</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>newsbox</name>
<build>
<finalName>newsbox</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- Run the application using "mvn embedded-glassfish:run" -->
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>${glassfish.version}</version>
<configuration>
<goalPrefix>embedded-glassfish</goalPrefix>
<app>D:\Java\workspace/target/${project.build.finalName}.war</app>
<autoDelete>true</autoDelete>
<port>8080</port>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<!-- Instructing the resources plugin to filter certain directories -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<properties>
<jersey.version>1.17.1</jersey.version>
<glassfish.version>3.1.1</glassfish.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- Profiles start here -->
<profiles>
<!-- Development environment @ my laptop, mvn <package> -P development -->
<profile>
<id>development</id>
<properties>
<db.driverClass>oracle.jdbc.driver.OracleDriver</db.driverClass>
<db.connectionURL>.....</db.connectionURL>
<db.username>wf</db.username>
<db.password>....</db.password>
</properties>
</profile>
<!-- Development environment @ my laptop, mvn <package> -P quality -->
<profile>
<id>quality</id>
<properties>
<db.driverClass>oracle.jdbc.driver.OracleDriver</db.driverClass>
<db.connectionURL>......</db.connectionURL>
<db.username>webaccess</db.username>
<db.password>....</db.password>
</properties>
</profile>
<!-- Production environment @ production server, mvn <package> -P production -->
<profile>
<id>production</id>
<properties>
<db.driverClass>oracle.jdbc.driver.OracleDriver</db.driverClass>
<db.connectionURL>.....</db.connectionURL>
<db.username>webaccess</db.username>
<db.password>....</db.password>
</properties>
</profile>
</profiles>
</project>
- 我會使用Maven構建只有一次戰爭文件。
它將部署在我的質量環境 戰爭文件,完成後在我的部署 應用CAT「Q部署完畢,開始P部署」按鈕 將被啓用。
如果我現在按一下按鈕它只有質量 數據源,如何使生產數據來源應該是 accessed.???It應該採取P個數據源默認情況下, 參考。?? ?
謝謝。