简体   繁体   中英

Where are the application.properties files in a spring boot jar?

I have a spring boot app (2.0.1) with embedded Tomcat that has been assembled into an executable jar via mvn clean package springboot:repackage. The application runs perfectly.

We have a security requirement that states that the passwords used must be encrypted in the property files. They are ( with jasypt). I am using @ConfigurationProperties to inject them into classes.

As part of a QA test, the testers need to see the encrypted properties.

My question is, when I open the jar file, I can't find the application.properties files. Are they not loaded in the jar? Preinjected at compile time based on the environment?

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>

在此处输入图片说明

application.properties 文件位于 JAR 文件中:

BOOT-INF\classes\application.properties 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM