春季启动jar中的application.properties文件在哪里?

时间:2018-10-12 14:08:09

标签: java maven spring-boot

我有一个带有嵌入式Tomcat的Spring Boot应用程序(2.0.1),该应用程序已通过mvn clean package springboot:repackage组装成一个可执行jar。该应用程序运行完美。

我们有一个安全要求,要求使用的密码必须在属性文件中加密。它们是(带有jasypt)。我正在使用@ConfigurationProperties将它们注入类中。

作为质量检查测试的一部分,测试人员需要查看加密的属性。

我的问题是,当我打开jar文件时,找不到application.properties文件。他们不是装在罐子里吗?是在编译时根据环境预先注入的?

谢谢

pom.xml

<groupId>com.jebrick.rim</groupId>
<artifactId>regulusConnector</artifactId>
<version>1.0-QA-RELEASE</version>
<packaging>jar</packaging>

<name>regulusConnector</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
  <cxf.version>3.2.5</cxf.version>
  <spring-cloud.version>Dalston.SR1</spring-cloud.version>
  <tomcat.version>8.5.34</tomcat.version>
  <mainClass>com.jebrick.rim.App</mainClass>
 </properties>

 <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
  </parent>

 <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
  <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <exclusions>
          <!--<exclusion>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-logging</artifactId>
          </exclusion>-->
      </exclusions>
   </dependency>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
   </dependency>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-configuration-processor</artifactId>
      <optional>true</optional>
  </dependency>

  <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
      <scope>provided</scope>

  </dependency>
  <dependency>
      <groupId>org.apache.tomcat.embed</groupId>
      <artifactId>tomcat-embed-jasper</artifactId>
      <scope>provided</scope>

  </dependency>
  <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <version>2.0.1.RELEASE</version>
      <optional>true</optional>
  </dependency>
 more dependencies

<build>
 <resources>
      <resource>
          <directory>resources</directory>
          <targetPath>src/main/java/resources</targetPath>
          <includes>
              <include>*.properties</include>
          </includes>
      </resource>
  </resources>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
  <plugins>
      <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <configuration>
              <mainClass>com.jebrick.rim.App</mainClass>
          </configuration>
          <executions>
              <execution>
                  <goals>
                      <goal>repackage</goal>
                  </goals>
              </execution>
          </executions>
      </plugin>
<plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-surefire-plugin.version}</version>
          <configuration>
              <!-- Force alphabetical order to have a reproducible build -->
              <runOrder>alphabetical</runOrder>
          </configuration>
      </plugin>
      <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.1.0</version>

      </plugin>
  </plugins>
 </pluginManagement>
</build>

enter image description here

1 个答案:

答案 0 :(得分:0)

application.properties文件位于以下位置的JAR文件中:

BOOT-INF\classes\application.properties