Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何将变量设置为pom.xml中的数据库密码_Java_Maven_Jenkins_Environment Variables_Pom.xml - Fatal编程技术网

Java 如何将变量设置为pom.xml中的数据库密码

Java 如何将变量设置为pom.xml中的数据库密码,java,maven,jenkins,environment-variables,pom.xml,Java,Maven,Jenkins,Environment Variables,Pom.xml,我需要在pom的配置文件中配置一个Jenkins变量作为我的密码数据库,但是如果我设置${env.passwordb}(如下所示),项目将不会编译并出现一些错误,但是如果我将代码推送到Jenkins,它将获取该变量并完美地运行项目。我需要改变什么 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://

我需要在pom的配置文件中配置一个Jenkins变量作为我的密码数据库,但是如果我设置
${env.passwordb}
(如下所示),项目将不会编译并出现一些错误,但是如果我将代码推送到Jenkins,它将获取该变量并完美地运行项目。我需要改变什么

<?xml version="1.0" encoding="UTF-8"?>
<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>com.company.vrs</groupId>
    <artifactId>company-vrs</artifactId>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <url>${env.urlTomcat}</url>
                    <path>${env.appPath}</path>
                    <username>${env.username}</username>
                    <password>${env.password}</password>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <packaging>war</packaging>
    <name>company-vrs</name>
    <url>http://maven.apache.org</url>
    <profiles>
        <profile>
            <id>dev</id>
            <build>
                <finalName>visitors</finalName>
                <resources>
                    <resource>
                        <directory>src/main/resources</directory>
                        <filtering>true</filtering>
                        <excludes>
                            <exclude>**/*.jks</exclude>
                        </excludes>
                    </resource>
                    <resource>
                        <directory>src/main/resources</directory>
                        <filtering>false</filtering>
                        <includes>
                            <include>**/*.jks</include>
                        </includes>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.3</version>
                        <configuration>
                            <mainClass>com.company.vrs.config.AppConfig</mainClass>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>2.4</version>
                        <configuration>
                            <failOnMissingWebXml>false</failOnMissingWebXml>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.eclipse.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>
                        <version>9.2.0.RC0</version>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.tomcat.maven</groupId>asta que
                        <artifactId>tomcat7-maven-plugin</artifactId>
                        <version>2.2</version>
                        <configuration>
                            <port>9090</port>
                            <path>/</path>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <db.url>jdbc:postgresql://hsvvrsdev.company.com:5432/vrs_dev</db.url>
                <db.username>vrsuser</db.username>
                <db.password>${env.passworddb}</db.password>
                <isdev>true</isdev>
                <realm.metadata.file>/metadata/secureAuth_dev.xml</realm.metadata.file>
                <realm.metadata.url>https://ssodev.company.com/SecureAuth68/metadata.xml</realm.metadata.url>
                <realm.url.restart>https://ssodev.company.com/SecureAuth68/restart.aspx</realm.url.restart>
            </properties>
        </profile>
        <profile>
            <id>sqa</id>
            <build>
                <finalName>visitors_sqa</finalName>
                <resources>
                    <resource>
                        <directory>src/main/resources</directory>
                        <filtering>true</filtering>
                        <excludes>
                            <exclude>**/*.jks</exclude>
                        </excludes>
                    </resource>
                    <resource>
                        <directory>src/main/resources</directory>
                        <filtering>false</filtering>
                        <includes>
                            <include>**/*.jks</include>
                        </includes>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.3</version>
                        <configuration>
                            <mainClass>com.company.vrs.config.AppConfig</mainClass>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>2.4</version>
                        <configuration>
                            <failOnMissingWebXml>false</failOnMissingWebXml>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.eclipse.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>
                        <version>9.2.0.v20140526</version>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.tomcat.maven</groupId>
                        <artifactId>tomcat7-maven-plugin</artifactId>
                        <version>2.2</version>
                        <configuration>
                            <port>9090</port>
                            <path>/</path>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <db.url>jdbc:postgresql://hsvvrsdev.company.com:5432/vrs_sqa</db.url>
                <db.username>vrsuser</db.username>
                <db.password>vrs#2015!</db.password>
                <istest>true</istest>
                <realm.metadata.file>/metadata/secureAuth_dev.xml</realm.metadata.file>
                <realm.metadata.url>https://ssodev.company.com/SecureAuth68/metadata.xml</realm.metadata.url>
                <realm.url.restart>https://ssodev.company.com/SecureAuth68/restart.aspx</realm.url.restart>
            </properties>
        </profile>
        <profile>
            <id>pro</id>
            <build>
                <finalName>visitors</finalName>
                <resources>
                    <resource>
                        <directory>src/main/resources</directory>
                        <filtering>true</filtering>
                        <excludes>
                            <exclude>**/*.jks</exclude>
                        </excludes>
                    </resource>
                    <resource>
                        <directory>src/main/resources</directory>
                        <filtering>false</filtering>
                        <includes>
                            <include>**/*.jks</include>
                        </includes>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.3</version>
                        <configuration>
                            <mainClass>com.company.vrs.config.AppConfig</mainClass>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>2.4</version>
                        <configuration>
                            <failOnMissingWebXml>false</failOnMissingWebXml>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.eclipse.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>
                        <version>9.2.0.v20140526</version>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.tomcat.maven</groupId>
                        <artifactId>tomcat7-maven-plugin</artifactId>
                        <version>2.2</version>
                        <configuration>
                            <port>9090</port>
                            <path>/</path>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <db.url>jdbc:postgresql://hsvvrsdb.company.com:5432/vrs</db.url>
                <db.username>vrsuser</db.username>
                <db.password>v14r3s20150302</db.password>
                <ispro>true</ispro>
                <realm.metadata.file>/metadata/secureAuth_prod.xml</realm.metadata.file>
                <realm.metadata.url>https://sso.company.com/visitors/metadata.xml</realm.metadata.url>
                <realm.url.restart>https://sso.company.com/visitors/restart.aspx</realm.url.restart>
            </properties>
        </profile>
    </profiles>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring-version>4.1.2.RELEASE</spring-version>
        <spring-data-jpa-version>1.6.1.RELEASE</spring-data-jpa-version>
        <spring-data-commons-version>1.8.1.RELEASE</spring-data-commons-version>
        <hibernate-version>4.3.5.Final</hibernate-version>
        <org-slf4j-version>1.7.7</org-slf4j-version>
        <spring-ldap-version>2.0.1.RELEASE</spring-ldap-version>
        <spring-security-version>3.2.3.RELEASE</spring-security-version>
        <bonecp-version>0.8.0.RELEASE</bonecp-version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <dependencies>
           ..... many dependencies ....        
    </dependencies>
</project>

4.0.0
com.company.vrs
vrs公司
1.0-快照
org.apache.tomcat.maven
tomcat7 maven插件
2.2
${env.urlTomcat}
${env.appPath}
${env.username}
${env.password}
org.apache.maven.plugins
maven战争插件
2.4
假的
org.apache.maven.plugins
maven编译器插件
2.4
1.8
1.8
战争
vrs公司
http://maven.apache.org
发展
来访者
src/main/resources
真的
**/*.jks
src/main/resources
假的
**/*.jks
org.codehaus.mojo
execmaven插件
1.3
com.company.vrs.config.AppConfig
org.apache.maven.plugins
maven战争插件
2.4
假的
org.eclipse.jetty
jetty maven插件
9.2.0.RC0
org.apache.tomcat.mavenasta que
tomcat7 maven插件
2.2
9090
/
jdbc:postgresql://hsvvrsdev.company.com:5432/vrs_dev
弗苏瑟
${env.passworddb}
真的
/元数据/secureAuth_dev.xml
https://ssodev.company.com/SecureAuth68/metadata.xml
https://ssodev.company.com/SecureAuth68/restart.aspx
sqa
访客区
src/main/resources
真的
**/*.jks
src/main/resources
假的
**/*.jks
org.codehaus.mojo
execmaven插件
1.3
com.company.vrs.config.AppConfig
org.apache.maven.plugins
maven战争插件
2.4
假的
org.eclipse.jetty
jetty maven插件
9.2.0.v20140526
org.apache.tomcat.maven
tomcat7 maven插件
2.2
9090
/
jdbc:postgresql://hsvvrsdev.company.com:5432/vrs_sqa
弗苏瑟
vrs#2015!
真的
/元数据/secureAuth_dev.xml
https://ssodev.company.com/SecureAuth68/metadata.xml
https://ssodev.company.com/SecureAuth68/restart.aspx
赞成的意见
来访者
src/main/resources
真的
**/*.jks
src/main/resources
假的
**/*.jks
org.codehaus.mojo
execmaven插件
1.3
com.company.vrs.config.AppConfig
org.apache.maven.plugins
maven战争插件
2.4
假的
mvn clean package resources:testResources -Denv.passwddb=realpass