Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven资源筛选不起作用-因为spring启动依赖关系_Java_Maven_Spring Boot - Fatal编程技术网

Java Maven资源筛选不起作用-因为spring启动依赖关系

Java Maven资源筛选不起作用-因为spring启动依赖关系,java,maven,spring-boot,Java,Maven,Spring Boot,在一个maven项目中,我试图使用maven资源过滤替换一些令牌,但它不起作用。我有一些其他项目的工作,但不工作,在这个单一的项目不知道什么是错误的 属性文件位于/src/main/resources/my.properties位置 我尝试了不同的maven命令,如下所示,但不起作用 mvn clean install mvn clean install resources:resources my.properties ### Spring boot properties jdbc.url=

在一个maven项目中,我试图使用maven资源过滤替换一些令牌,但它不起作用。我有一些其他项目的工作,但不工作,在这个单一的项目不知道什么是错误的

属性文件位于/src/main/resources/my.properties位置

我尝试了不同的maven命令,如下所示,但不起作用

mvn clean install
mvn clean install resources:resources
my.properties

### Spring boot properties
jdbc.url=${jdbc.url}
ldap.domain=${ldap_domain}
ldap.url=${ldap_url}
pom.xml

    <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.jai</groupId>
    <artifactId>client</artifactId>
    <version>0.0.6-SNAPSHOT</version>
    <name>client</name>
    <description>client web application</description>
    <packaging>war</packaging>

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


    <dependencies>

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

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

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-ldap</artifactId>
        </dependency>

    </dependencies>

    <build>
        <finalName>client</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>
            </plugin>

            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>exec-bower-install</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <executable>bower</executable>
                            <arguments>
                                <argument>install</argument>
                            </arguments>
                        </configuration>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>

    </build>


    <profiles>
        <!-- localhost environment -->
        <profile>
            <id>local</id>

            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

            <properties>

                <ldap_domain>mydomain.local</ldap_domain>
                <ldap_url>ldap://server:389</ldap_url>
                <jdbc.url>testttttttttttttttttttttt</jdbc.url>

            </properties>
        </profile>

        </profiles>

</project>

4.0.0
com.jai
客户
0.0.6-快照
客户
客户端web应用程序
战争
org.springframework.boot
spring启动程序父级
1.3.2.1发布
org.springframework.boot
弹簧启动安全
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧启动机tomcat
假如
org.springframework.boot
弹簧起动试验
测试
org.springframework.security
spring安全ldap
客户
src/main/resources
真的
org.springframework.boot
springbootmaven插件
maven战争插件
网络内容
假的
org.codehaus.mojo
execmaven插件
exec-bower安装
生成源
凉亭
安装
执行官
地方的
真的
mydomain.local
ldap://server:389
testttttttttttttttttttttttttttt
更新:-

我发现这个问题是由spring引导依赖性引起的。
如果我对
部分和其他spring引导依赖项进行注释,那么它工作正常,能够替换令牌。但是仍然不知道如何通过保持spring boot来解决这个问题。

终于在我的评论中找到了答案。因为这是一个spring启动应用程序…特殊情况。。。符号应该是

@xxxxx@  instead of ${xxxxx}
因此,我的属性文件如下所示

### Spring boot properties
jdbc.url=@jdbc.url@
ldap.domain=@ldap_domain@
ldap.url=@ldap_url@

这似乎是spring boot中的一个缺陷,但spring boot 1.5.9中仍然存在一个问题。Release为了防止人们打猎,在SB 1.3.0中对其进行了更改。这是谢谢你的礼物。帮我大忙!我正在使用@,但仍然不起作用。我正在尝试在生成期间注入属性。mvn clean install-DsecretProperty=hello,在我的属性文件value中有一个属性。from.file=@secretProperties@我运行Spring启动应用程序时得到的是->@secretProperties@