美文网首页微服务
加载src下xml配置

加载src下xml配置

作者: 田涛347 | 来源:发表于2021-03-09 14:07 被阅读0次

    在Application启动类添加@ComponentScan注解

    @ComponentScan(basePackages = {"com.flh.uaa","com.flh.common.config"})

    在pom.xml的

    build->plugins下添加插件maven-resources-plugin

    maven-resources-plugin节点下的executions节点的添加拷贝资源文件execution

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>${maven-resources-plugin.version}</version>
            <executions>
                <execution>
                    <id>default-resources</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/classes</outputDirectory>
                        <useDefaultDelimiters>false</useDefaultDelimiters>
                        <delimiters>
                            <delimiter>#</delimiter>
                        </delimiters>
                        <resources>
                            <resource>
                                <directory>src/main/java</directory>
                                <includes>
                                    <include>**/*.xml</include>
                                </includes>
                            </resource>
                            <resource>
                                <directory>src/main/resources/</directory>
                                <filtering>false</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    

    在pom的build节点上添加resources节点

    build→resources

    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.xml</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/resources/</directory>
            <filtering>false</filtering>
        </resource>
    </resources>
    

    相关文章

      网友评论

        本文标题:加载src下xml配置

        本文链接:https://www.haomeiwen.com/subject/pscrqltx.html