我想在Spring中从基于XML的配置切换到基于Java的配置.现在我们在应用程序上下文中有这样的东西:
<context:component-scan base-package="foo.bar">
<context:exclude-filter type="annotation" expression="o.s.s.Service"/>
</context:component-scan>
<context:component-scan base-package="foo.baz" />
Run Code Online (Sandbox Code Playgroud)
但如果我写这样的东西......
@ComponentScan(
basePackages = {"foo.bar", "foo.baz"},
excludeFilters = @ComponentScan.Filter(
value= Service.class,
type = FilterType.ANNOTATION
)
)
Run Code Online (Sandbox Code Playgroud)
...它将从两个包中排除服务.我有强烈的感觉,我忽略了一些令人尴尬的琐碎,但我找不到一个解决方案来限制过滤器的范围foo.bar.
目前我有一个Web应用程序,我们使用web.xml来配置应用程序.web.xml有welcome-file-list.
<web-app>
...
<welcome-file-list>
<welcome-file>home.html</welcome-file>
</welcome-file-list>
</web-app>
Run Code Online (Sandbox Code Playgroud)
我们计划使用spring框架并使用java类进行应用程序配置.
class MyApplication extends WebApplicationInitializer {
public void onStartUp(ServletContext context){
...
}
}
Run Code Online (Sandbox Code Playgroud)
如何在此java类中指定welcome-file-list?