我是春天新来的,我遇到了麻烦。当我使用 IntelliJ Idea 运行我的应用程序时,一切正常,但是当我将它编译为 .jar 应用程序时,这给了我这个错误java.lang.IllegalArgumentException: Could not resolve placeholder 'jwt.secret' in value "${jwt.secret}"
这是我application.yml位于src/main/resources
#Config Application
jwt:
header: Authorization
secret: mySecret
expiration: 604800
route:
authentication:
path: auth
refresh: refresh
token: check
Run Code Online (Sandbox Code Playgroud)
当我改变我的这个它工作完美。
// @Value("${jwt.secret}")
@Value("mySecret")
private String secret;
Run Code Online (Sandbox Code Playgroud)
我在做什么错?
注意:我正在使用 MAVEN
这是我的 pom.xml
<?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.example.test</groupId>
<artifactId>test-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test-app</name>
<description>Test</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<jjwt.version>0.7.0</jjwt.version> …Run Code Online (Sandbox Code Playgroud)