[quote=引用 18 楼 lkl713 的回复:] [quote=引用 15 楼 suciver 的回复:] [quote=引用 14 楼 lkl713 的回复:] Socket类无法交给spring管理,那就无法给serverSession注入socket,除了用new来新建ServerSession,貌似没有办法了
前几天碰到过类似的问题,可以这样做 HttpServletRequest request = ServletActionContext.getRequest(); ServletContext sc = request.getSession().getServletContext(); WebApplicationContext webAppCtx = WebApplicationContextUtils.getRequiredWebApplicationContext(sc); 你要的bean bean = (你要的bean) webAppCtx .getBean("你要的bean");
[quote=引用 15 楼 suciver 的回复:] [quote=引用 14 楼 lkl713 的回复:] Socket类无法交给spring管理,那就无法给serverSession注入socket,除了用new来新建ServerSession,貌似没有办法了
[quote=引用 14 楼 lkl713 的回复:] Socket类无法交给spring管理,那就无法给serverSession注入socket,除了用new来新建ServerSession,貌似没有办法了
Socket类无法交给spring管理,那就无法给serverSession注入socket,除了用new来新建ServerSession,貌似没有办法了
ServerSession必须作为一个bean给spring管理才行,否则,要用那个xxxUtils获得context再getBean才行
楼主不是在Server的new而是在Server的run方法里面new ServerSession这样的自然不是spring所创建的ServerSession实例也就不会注入成功了
我想你应该把调用的地方也粘贴出来,我觉得是你调用的时候对象出现的问题
[quote=引用 6 楼 suciver 的回复:] 你spring的配置文件里<context:component-scan base-package="" />这个注解扫描基本的包有包括你的这个类吗
你spring的配置文件里<context:component-scan base-package="" />这个注解扫描基本的包有包括你的这个类吗
81,092
社区成员
341,717
社区内容
加载中
试试用AI创作助手写篇文章吧