当前位置: 首页 > 知识库问答 >
问题:

在spring中编写上下文文件

唐法
2023-03-14

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd“>

   <import resource="classpath:context2.xml"/>

   <import resource="classpath:context3.xml" />

这里context1.xml是由context2.xml编写的,context1.xml和context2.xml都是MDB的。context3.xml没有问题。Context1和context2具有一些相同的Bean ID,但具有不同的属性和引用。

共有1个答案

鱼志诚
2023-03-14

我找到了解决办法。我使用相同的Bean ID,并认为这是一个预定义的Bean ID。我对春天的知识不多。所以我研究了一下,发现你可以为你所引用的类提供你想要的任何bean ID。

 类似资料:
  • 今天,我将我的项目从Spring Boot1.5.9更新到2.1.1,我的一些测试停止工作。当我开始测试时,控制台会弹出错误: com.example.rest.config.SecurityConfig中的authEntryPoint字段需要一个类型为“com.example.rest.service.auth.EntryPoints.AuthenticationEntryPoint”的bean

  • 问题内容: 我有一个Spring bean(dao)对象,该对象通过以下xml在ServletContext中实例化: 该bean在我的webapp-servlet.xml文件中声明,并由我的应用程序在ServletContext中使用。 我也在使用SpringSecurity。据我了解,这在不同的上下文(SecurityContext)中运行。 我的应用程序具有webapp-security.x

  • 这段代码既不写文件,也不给我一个错误,这是日志: 开始请求ID:7c93b1b9-73c1-4f18-9824-095bcbe292bf版本:$最新结束请求ID:7c93b1b9-73c1-4f18-9824-095bcbe292bf报告请求ID:7c93b1b9-73c1-4f18-9824-095bcbe292bf持续时间:706.18 ms计费持续时间:800 ms内存大小:128 MB最大

  • 我有一个使用子/父上下文关系的Spring应用程序。这样做的原因是为了确保子上下文从父上下文继承bean/资源,然后根据需要添加更多bean/资源来覆盖它们。但是,当子上下文关闭时(退出try/catch作用域),它开始对它引用的所有bean进行清理,包括父作用域中的bean。这是不可取的,因为我需要重用父上下文来创建另一个子上下文,但是现在它是垃圾,因为它包含了一堆已处理/关闭的bean。 问题

  • > http://projectreactor.io/docs/core/release/reference/#context https://jira.spring.io/browse/spr-15680 https://simonbasle.github.io/2018/02/contextual-logging-with-reactor-context-and-mdc/。 产出:

  • 问题内容: 我正在Django(1.11)上编写自己的自定义,并从auth0获取经过身份验证的用户的信息。这不是我第一次写它,我也不知道这个错误是从哪里来的: ImportError:模块“ auth.context_processors”未定义“ auth0_processors”属性/类 看起来是这样的: auth / settings.py: auth / context_processor