mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
feat: 新增使用注解注入SpringUtil的方式
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package cn.hutool.extra.spring;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author sidian
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = EnableSprintUtilTest.class)
|
||||
@EnableSpringUtil
|
||||
public class EnableSprintUtilTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
// 使用@EnableSpringUtil注解后, 能获取上下文
|
||||
Assert.assertNotNull(SpringUtil.getApplicationContext());
|
||||
// 不使用时, 为null
|
||||
// Assert.assertNull(SpringUtil.getApplicationContext());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user