簡體   English   中英

如何將 applicationContext.xml 和 Bean 從外部 jar 導入@SpringBootTest?

[英]How to import applicationContext.xml and Bean from external jar to @SpringBootTest?

我有一個測試:

@SpringBootTest
public class MyTest {
...
}

我有外部 jar,它有類 MyService(帶有 @Service)和 applicationContext.xml(為 MyService 創建 beans-args)。 如何將它們導入 MyTest? 我想檢查一下,我的 bean 是否已創建。

我的調查結果:

  1. 來自外部 jar 的 Bean 將由 Spring 自動創建。
  2. 應用程序上下文可以像這樣導入:
@ContextConfiguration(locations = {"classpath*:applicationContext.xml"})
@SpringBootTest
public class MyTest{
...
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM