本文整理汇总了Java中org.springframework.web.context.support.AnnotationConfigWebApplicationContext.getBean方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationConfigWebApplicationContext.getBean方法的具体用法?Java AnnotationConfigWebApplicationContext.getBean怎么用?Java AnnotationConfigWebApplicationContext.getBean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.context.support.AnnotationConfigWebApplicationContext
的用法示例。
在下文中一共展示了AnnotationConfigWebApplicationContext.getBean方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
@Before
@SuppressWarnings("resource")
public void setup() throws Exception {
this.filterChain = new MockFilterChain(this.servlet, new ResourceUrlEncodingFilter());
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setServletContext(new MockServletContext());
context.register(WebConfig.class);
context.refresh();
this.request = new MockHttpServletRequest("GET", "/");
this.request.setContextPath("/myapp");
this.response = new MockHttpServletResponse();
Object urlProvider = context.getBean(ResourceUrlProvider.class);
this.request.setAttribute(ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR, urlProvider);
}
示例2: getToolContext
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
private ToolContext getToolContext(String toolboxConfigLocation) throws Exception {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setServletContext(new MockServletContext());
context.register(Config.class);
context.refresh();
EmbeddedVelocityToolboxView view = context
.getBean(EmbeddedVelocityToolboxView.class);
view.setToolboxConfigLocation(toolboxConfigLocation);
Map<String, Object> model = new LinkedHashMap<String, Object>();
HttpServletRequest request = new MockHttpServletRequest();
HttpServletResponse response = new MockHttpServletResponse();
ToolContext toolContext = (ToolContext) view.createVelocityContext(model, request,
response);
context.close();
return toolContext;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:EmbeddedVelocityToolboxViewTests.java
示例3: testCustomShellProperties
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
@Test
public void testCustomShellProperties() throws Exception {
MockEnvironment env = new MockEnvironment();
env.setProperty("management.shell.auth.type", "simple");
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.setEnvironment(env);
ctx.setServletContext(new MockServletContext());
ctx.register(TestShellConfiguration.class);
ctx.register(CrshAutoConfiguration.class);
ctx.refresh();
PluginLifeCycle lifeCycle = ctx.getBean(PluginLifeCycle.class);
String uuid = lifeCycle.getConfig().getProperty("test.uuid");
assertThat(uuid).isEqualTo(TestShellConfiguration.uuid);
ctx.close();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:ShellPropertiesTests.java
示例4: initializeOnce
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
@Test
public void initializeOnce() throws Exception {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setServletContext(new MockServletContext());
context.register(HandlerMappingConfiguration.class);
context.refresh();
ResourceUrlProvider translator = context.getBean(ResourceUrlProvider.class);
assertThat(translator.getHandlerMap(), Matchers.hasKey("/resources/**"));
assertFalse(translator.isAutodetect());
}
示例5: init
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
@BeforeClass
public static void init() throws SQLException, IOException {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(DBConfig.class);
context.refresh();
DataSource ds = (DataSource) context.getBean("dataSource");
try (Connection conn = ds.getConnection()) {
initData(conn);
}
}
示例6: initDB
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
@BeforeClass
public static void initDB() throws SQLException, IOException {
@SuppressWarnings("resource")
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(DBHikaricpH2Config.class);
context.register(MybatisConfigMetaObjOptLockConfig.class);
context.refresh();
DataSource ds = (DataSource) context.getBean("dataSource");
try (Connection conn = ds.getConnection()) {
initData(conn);
}
}
示例7: init
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
@BeforeClass
public static void init() throws SQLException, IOException {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(ServiceConfig.class);
context.refresh();
DataSource ds = (DataSource) context.getBean("dataSource");
try (Connection conn = ds.getConnection()) {
initData(conn);
}
}
示例8: initDB
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
@BeforeClass
public static void initDB() throws SQLException, IOException {
@SuppressWarnings("resource")
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(DBConfig.class);
context.register(MybatisConfigMetaObjOptLockConfig.class);
context.refresh();
DataSource ds = (DataSource) context.getBean("dataSource");
try (Connection conn = ds.getConnection()) {
initData(conn);
}
}