Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/399.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 Spring boot如何导入所有jar依赖项目的所有i18n消息?_Java_Spring_Maven_Spring Boot_Internationalization - Fatal编程技术网

Java Spring boot如何导入所有jar依赖项目的所有i18n消息?

Java Spring boot如何导入所有jar依赖项目的所有i18n消息?,java,spring,maven,spring-boot,internationalization,Java,Spring,Maven,Spring Boot,Internationalization,我想导入所有messages.properties文件,它们包含在我的项目的所有jar依赖项的src/main/resource/messages位置中。 例如: 项目A导入->项目B,我需要加载所有消息属性 我试过: @Bean public ReloadableResourceBundleMessageSource messageSource() { ReloadableResourceBundleMessageSource messageSource = new ReloadableR

我想导入所有messages.properties文件,它们包含在我的项目的所有jar依赖项的src/main/resource/messages位置中。 例如: 项目A导入->项目B,我需要加载所有消息属性

我试过:

@Bean
public ReloadableResourceBundleMessageSource messageSource() {
  ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
  messageSource.setBasenames("classpath:/messages", "classpath:/messages/messages");
  messageSource.setCacheSeconds(3600);
  return messageSource;
}
但是它不起作用=(。我怎样才能用spring boot做到这一点

以下是我的项目结构:

project A
+-- project-server-business
¦   +-- src
¦   ¦   +-- main
¦   ¦   ¦   +-- java
¦   ¦   ¦   +-- resources
¦   ¦   ¦   ¦   +-- messages
¦   ¦   ¦   ¦   ¦  +-- messages-business.properties
¦   +-- pom.xml
+-- project-server-service
¦   +-- src
¦   ¦   +-- main
¦   ¦   ¦   +-- java
¦   ¦   ¦   +-- resources
¦   ¦   ¦   ¦   +-- messages
¦   ¦   ¦   ¦   ¦  +-- messages-business.properties
¦   +-- pom.xml
+-- pom.xml

project B
+-- project-server-business
¦   +-- src
¦   ¦   +-- main
¦   ¦   ¦   +-- java
¦   ¦   ¦   +-- resources
¦   ¦   ¦   ¦   +-- messages
¦   ¦   ¦   ¦   ¦  +-- messages-business.properties
¦   +-- pom.xml
+-- project-server-service
¦   +-- src
¦   ¦   +-- main
¦   ¦   ¦   +-- java
¦   ¦   ¦   +-- resources
¦   ¦   ¦   ¦   +-- messages
¦   ¦   ¦   ¦   ¦  +-- messages-business.properties
¦   +-- pom.xml
+-- pom.xml
<build>

        <resources>
            <resource>
                <directory>src${file.separator}main${file.separator}resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <pluginManagement>
            <plugins>   
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring.boot.version}</version>
                    <configuration>
                        <source>${maven.plugin.target}</source>
                        <target>${maven.plugin.target}</target>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${maven.war.plugin.version}</version>
                </plugin>

                <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <version>${maven.compiler.plugin.version}</version>
                  <configuration>
                    <source>${maven.plugin.target}</source>
                    <target>${maven.plugin.target}</target>
                  </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
  </build>
我的pom构建结构:

project A
+-- project-server-business
¦   +-- src
¦   ¦   +-- main
¦   ¦   ¦   +-- java
¦   ¦   ¦   +-- resources
¦   ¦   ¦   ¦   +-- messages
¦   ¦   ¦   ¦   ¦  +-- messages-business.properties
¦   +-- pom.xml
+-- project-server-service
¦   +-- src
¦   ¦   +-- main
¦   ¦   ¦   +-- java
¦   ¦   ¦   +-- resources
¦   ¦   ¦   ¦   +-- messages
¦   ¦   ¦   ¦   ¦  +-- messages-business.properties
¦   +-- pom.xml
+-- pom.xml

project B
+-- project-server-business
¦   +-- src
¦   ¦   +-- main
¦   ¦   ¦   +-- java
¦   ¦   ¦   +-- resources
¦   ¦   ¦   ¦   +-- messages
¦   ¦   ¦   ¦   ¦  +-- messages-business.properties
¦   +-- pom.xml
+-- project-server-service
¦   +-- src
¦   ¦   +-- main
¦   ¦   ¦   +-- java
¦   ¦   ¦   +-- resources
¦   ¦   ¦   ¦   +-- messages
¦   ¦   ¦   ¦   ¦  +-- messages-business.properties
¦   +-- pom.xml
+-- pom.xml
<build>

        <resources>
            <resource>
                <directory>src${file.separator}main${file.separator}resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <pluginManagement>
            <plugins>   
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring.boot.version}</version>
                    <configuration>
                        <source>${maven.plugin.target}</source>
                        <target>${maven.plugin.target}</target>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${maven.war.plugin.version}</version>
                </plugin>

                <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <version>${maven.compiler.plugin.version}</version>
                  <configuration>
                    <source>${maven.plugin.target}</source>
                    <target>${maven.plugin.target}</target>
                  </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
  </build>

src${file.separator}主${file.separator}资源
真的
org.springframework.boot
springbootmaven插件
${spring.boot.version}
${maven.plugin.target}
${maven.plugin.target}
假的
org.apache.maven.plugins
maven战争插件
${maven.war.plugin.version}
org.apache.maven.plugins
maven编译器插件
${maven.compiler.plugin.version}
${maven.plugin.target}
${maven.plugin.target}

我对此也很感兴趣……你解决了吗?是的,但我现在没有解决方案,这是一个老项目。我将搜索该项目并在此处发布答案。