春天启动“无法解析占位符”

问题描述 投票:0回答:1

我正在使用Maven一个春天启动Tomcat应用程序。当我在IDE中运行它(的IntelliJ IDEA),它工作正常。然而,当我运行正常

java -jar myjar.jar

我得到一个异常

Caused by: java.lang.IllegalArgumentException: 
Could not resolve placeholder 'sysm.client.api.path' in value "${sysm.client.api.path}"

我使用JarLoader和PropertiesLauncher没有更好的运气也试过。

我有我的application.properties定义的属性sysm.client.api.path,但良好的措施我也把它添加到命令行的-D参数-Dsysm.client.api.path =我的路。

价值注入自己在一些依赖代码正在发生的事情,否则我会简单地硬编码值。

一注:的IntelliJ不运行它作为一个罐子;而它声明都在一个巨大的-classpath命令行参数的库,然后使用我的@SpringBootApplication类为可执行的类,完全不符合春季引导精神一致!

我很奇怪,为什么这个模块似乎得到了application.properties之前,其属性被加载,如果有任何方式重新排序,如此,它的工作原理

更新:我双重检查的jar和应用程序性能下BOOT-INF /班/ application.properties在那里。但由于某些原因,应用程序没有看到的是,在罐子。当我复制那些启动目录,它工作正常。不知道为什么这些没有被从罐子如预期回升?

<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>commy-group</groupId>
<artifactId>my-app</artifactId>
<version>2.0.1-SNAPSHOT</version>

<name>${project.artifactId}</name>
<url>http://maven.apache.org</url>

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

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <distribution.root>discovery-service-${project.version}</distribution.root>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <ansible.group>npc</ansible.group>
    <ansible.name>${project.artifactId}</ansible.name>
    <ansible.deploy>2018-1</ansible.deploy>
</properties>

<scm>
    <url>..</url>
    <connection>..</connection>
    <developerConnection>..</developerConnection>
</scm>

<distributionManagement>
    ...
</distributionManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>4.1.5.RELEASE</version>
    </dependency>

    <!-- ********************* SPRING ********************* -->
    <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-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.6.1</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-ldap</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-hateoas</artifactId>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
    </dependency>
</dependencies>

<build>
    <finalName>${project.artifactId}</finalName>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <executable>true</executable>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.4</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <doCheck>false</doCheck>
                <doUpdate>false</doUpdate>
                <shortRevisionLength>8</shortRevisionLength>
            </configuration>
        </plugin>
    </plugins>
</build>

spring spring-boot
1个回答
0
投票

找到了答案。我们有部署所有的罐子对于普通的Java应用程序的自定义部署。当然,这是没有必要的SpringBoot应用程序,因为所有的罐子都在内部(除主罐子和-bootstrapper.jar),但我希望它不伤应用程序的执行。

然而,当我删除了所有多余的罐子,应用程序突然开始认识到嵌入式application.properties。

我很想关闭这个问题,但也许它可能是有关谁有同样的情况的人吗?另外,我想知道为什么会出现这种现象? (只与某些应用程序发生。其他的正常工作与多余的罐子)

© www.soinside.com 2019 - 2024. All rights reserved.