简体   繁体   English

spring boot jar中的application.properties文件在哪里?

[英]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.我有一个带有嵌入式 Tomcat 的 Spring Boot 应用程序 (2.0.1),它已通过 mvn clean package springboot:repackage 组装到一个可执行的 jar 中。 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).他们是(与jasypt)。 I am using @ConfigurationProperties to inject them into classes.我正在使用 @ConfigurationProperties 将它们注入到类中。

As part of a QA test, the testers need to see the encrypted properties.作为 QA 测试的一部分,测试人员需要查看加密的属性。

My question is, when I open the jar file, I can't find the application.properties files.我的问题是,当我打开 jar 文件时,我找不到 application.properties 文件。 Are they not loaded in the jar?它们不是装在罐子里的吗? Preinjected at compile time based on the environment?根据环境在编译时预注入?

pom.xml 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 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将Spring Boot中的application.properties文件外部化为外部依赖JAR? - How to externalize application.properties files in Spring Boot to e.g. external dependent JAR? Spring Boot - 从依赖的 jar 加载 application.properties/yml - Spring Boot - Load application.properties/yml from dependent jar 在jar spring boot外部目录中搜索application.properties - Search application.properties in directory external to jar spring boot 使用 gradle 在 spring boot jar 中排除 application.properties - Exclude application.properties inside spring boot jar using gradle Spring启动jar没有读取/解析application.properties根文件夹 - Spring boot jar not reading/parsing application.properties root folder Spring 引导应用程序。导出到 jar 后找不到属性 - Spring Boot application.properties not found after exporting to jar 如何在Spring Boot中的application.properties中指定外部属性文件? - How to specify external properties files in application.properties in Spring Boot? Spring Boot 项目中的 application.properties 文件在哪里? - Where is the application.properties file in a Spring Boot project? 合并许多application.properties文件而不是Spring Boot上的替换? - merge many application.properties files instead of replace on Spring Boot? Spring 引导类路径配置文件覆盖外部 application.properties - Spring boot classpath configuration files overrides external application.properties
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM