我将Spring插入到现有的Java EE Web应用程序中.我的web.xml中有以下行:
<listener>
<listener-class>com.MyContextListener</listener-class>
</listener>
Run Code Online (Sandbox Code Playgroud)
而继MyContextListener类?
public class MyContextListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
//...
}
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能让MyContextListenerSpring管理?
编辑:
我的假设是:Spring应该创建所有servlet和所有Web应用程序基础结构,所以在contextInitialized方法中发生的一切都MyContextListener应该以某种方式由Spring处理.我怎么能通过实现一些接口来实现.如果我错了,请纠正我.谢谢!
我有一份清单employees.他们有isActive布尔字段.我想employees分成两个列表:activeEmployees和formerEmployees.是否可以使用Stream API?什么是最复杂的方式?
我对UrlClassLoader委派层次结构和继承层次结构感到困惑.我创建了扩展UrlClassLoader并执行的类:childOfUrlClassLoader.getParent().getClass().getName()
它给了我:
sun.misc.Launcher$AppClassLoader.在此之后我访问了上面提到的类(来源)
249 static class AppClassLoader extends URLClassLoader {
//...
308 protected synchronized Class<?> loadClass(String name, boolean resolve)
309 throws ClassNotFoundException
310 {
311 // First, check if the class has already been loaded
312 Class c = findLoadedClass(name);
313 if (c == null) {
314 try {
315 if (parent != null) {
316 c = parent.loadClass(name, false);
317
// ...
329 return c;
330 }
Run Code Online (Sandbox Code Playgroud)
然后我检查了谁是AppClassLoader的父级.我得到sun.misc.Launcher$ExtClassLoader了ExtClassLoader的父母null.
我有几个问题:
1)自从 …
我有可选对象:
Optional<Detail> newestDetail;
Run Code Online (Sandbox Code Playgroud)
我想返回newestDetail.getId()或者如果newestDetail是null返回null.
我们有更复杂的方法做到这一点,而不是遵循?
return newestDetail.isPresent()?newestDetail.get().getId():null;
Run Code Online (Sandbox Code Playgroud) 我想在Dockershell上运行shell命令Jenkins:
docker ps
是否可以不使用任何插件来完成它?由于Jenkins不是user,但是我可以添加一个服务帐户docker group?
我们应该同步写字符串吗?由于字符串是不可变的,因此从2个不同的线程写入和读取之间永远不会出现不一致的状态,对吗?
换句话说,为什么我们没有字符串类型的原子?
我有一个IDevice接口和这个接口的两个枚举实现:AndroidDevice和IosDevice.问题是:我想values()在接口引用上使用潜在的输入和调用方法:
private IDevice getDeviceByReadableName(String versionInXml, IDevice devices) {
for(IDevice device : devices.values()){
//...
Run Code Online (Sandbox Code Playgroud)
所以我必须添加public IDevice[] values();到我的界面:
public interface IDevice {
//...
public IDevice[] values();
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用.Eclipse问我remove static modifiers from AndroidDevice(...)
请:
我想DBbuildServletDispatcher在完成Context加载后加载,例如在 ApplicationListener<ContextRefreshedEvent>事件触发消息上构建(或继续构建)AppServletDispatcher Context
换句话说可以AppDispatcher Context等到完成创作DBbuild Context?这有什么常见的方法吗?
java ×8
classloader ×3
spring ×2
atomic ×1
collections ×1
concurrency ×1
docker ×1
enums ×1
go ×1
immutability ×1
inheritance ×1
java-8 ×1
java-stream ×1
jenkins ×1
nullable ×1
optional ×1
reduce ×1
servlets ×1
spring-mvc ×1
string ×1