2016-04-14 40 views
0

我有一個春天啓動的應用程序
我的應用程序的結構是加載外部配置類:
如何在春季啓動

src 
    main 
     java 
      org 
       Application.java 
       service 
         --another classes are here 

Application.java

package org.baharan; 
    import org.springframework.boot.SpringApplication; 
    import org.springframework.boot.autoconfigure.SpringBootApplication; 

    @SpringBootApplication 
    public class Application { 

     public static void main(String[] args) throws Throwable { 
      SpringApplication.run(Application.class, args); 
     } 
    } 

另一個confirguration類文件sush作爲oracle配置和安全配置在另一個應用程序中(被命名爲核心)添加到我的pom.xml中

 <dependency> 
      <groupId>org.baharan.amad</groupId> 
      <artifactId>core</artifactId> 
      <version>1.0-releases</version> 
      <type>war</type> 
     </dependency> 

當我構建我的應用程序時,核心應用程序的所有類和屬性文件都通過覆蓋添加到我的目標中maven
當我執行Application.java時,spring啓動程序找不到任何配置類不在我的應用程序,但他們在覈心(構建後,所有這些都添加到我的目標)
換句話說,如何彈簧啓動加載配置類不存在當前的應用程序。
請幫助我。

+0

http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html –

回答

0

如果它們是彈簧配置,仍然可以使用@ComponentScan加載其他bean配置,例如

@ComponentScan("classpath*:com.myorg.conf")

@ComponentScan("classpath*:conf/appCtx.xml")

+0

com.myorg.conf軟件包必須位於應用程序
中時,@ComponentScan才能工作com.myorg.conf軟件包位於web-inf/lib中的jar文件中,@ ComponentScan不起作用 –