【java – 添加了Spring Security,现在我收到“没有找到WebApplicationContext:没有注册ContextLoaderListener?”】教程文章相关的互联网学习教程文章

java-实现ApplicationContextAware-ApplicationContext为NULL【代码】

我正在编程一个Tomcat应用程序,该应用程序充当某些内部服务的代理. 我已经将Spring项目从混合的基于XML和基于注释的配置切换为Java和基于注释的配置. 在切换配置样式之前,该应用程序运行良好.现在我有两个问题. >在我的两个过滤器中执行初始化方法时,ApplicationContext为null.当我调试我的应用程序时,我可以看到方法setApplicationContext已执行.> EntityManagerFactory没有注入到认证过滤器中(emf为空) 引导Spring的代码: impor...

java-创建applicationContext.xml时出错:在ServletContext资源中定义名称为’sessionFactory’的bean时出错【代码】

我正在尝试使用Spring和Hibernate配置Java MVC Web应用程序,但是当我运行服务器时出现此错误,并且我不知道这是什么问题.ERROR: org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/applicationContext.xml]: Invocation of init met...

java-如何在Spring中将两个ApplicationContext彼此合并?【代码】

我的Spring Java模块中有两个上下文ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("SpringBeans.xml");和ClassPathXmlApplicationContext helloContext = new ClassPathXmlApplicationContext("HelloBeans.xml");与两个不同的xml文件.现在,我必须从上下文中获取HelloBeans.xml的bean,并从helloContext中获取SpringBeans.xml的bean,而无需刷新上下文.解决方法:找不到我想要的东西,但这是我能做的最...

java-Spring JSON视图:ApplicationObjectSupport不在ApplicationContext中运行

我正在尝试使用Spring的Json View(http://spring-json.sourceforge.net/)(org.springframework.web.servlet.view.json.JsonView),但是每当我编写扩展AbstractController的控制器类时,都会出现以下错误:java.lang.IllegalStateException: ApplicationObjectSupport instance [org.springframework.web.servlet.view.json.JsonView] does not run in an ApplicationContext奇怪的是,当我直接实现Controller接口并且不继承时,这很好....

java-Spring应用程序无法在Tomcat上部署:applicationContext有什么问题?【代码】

我的父pom.xml看起来像<dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>4.0.3.RELEASE</version> </dependency> <dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>4.0.3.RELEASE</version> </dependency> <dependency><groupId>org.springframework</groupId><artifactId>spring-web</artifactId><version>4.0.3.RELEASE</v...

java – 带有来自Jar的多个XML文件的Spring ApplicationContext【代码】

我需要使用当前Maven构建中的“main”applicationContext -a.xml创建一个ApplicationContext.另一个来自另一个maven构建的连接类,并在Maven依赖项包含的jar中预设. 这个想法:ApplicationContext context = new ClassPathXmlApplicationContext( new String[] {"classpath*:applicationContext-*.xml"});这应该从Classpath加载applicationContext-a.xml,因为它在同一个Project中.这有效. 然后应该从dependency-jar加载applicationC...

Java Spring多个ApplicationContext【代码】

SpringContextContext的定义非常模糊,我几乎完成了整本教程,但仍然无法理解ApplicationContext代表什么. 根据Spring API,ApplicationContext是:Central interface to provide configuration for an application. This is read-only while the application is running, but may be reloaded ifthe implementation supports this.The root interface for accessing a Spring bean container. This is the basic client view of a be...

java – 无法使用@ContextConfiguration加载ApplicationContext(classes = {…})【代码】

我正在尝试使用Java和注释配置运行一些弹簧测试.我在测试包中有两个配置类:@Configuration @ComponentScan(basePackages = "com.mypackages") public class TestConfig {@Beanpublic MyService getMyService() {return new MyServiceImpl();}}@Configuration @EnableTransactionManagement public class JpaTestConfig {@Beanpublic LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(){LocalContainerEntityMana...

java – Spring:JUnit-Test:未加载applicationContext【代码】

我有以下Test-class,但是我设置为“ContextConfiguration-locations”并不重要 – 它从不设置我的UserService.当我在locations-property中设置一个不存在的文件时,它不会抛出任何错误…我做错了什么?@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:applicationContextTest.xml" }) public class BasicPersistenceTest {@Autowired private UserService userService;@Test public void ...

java – Spring bean可以在applicationContext.xml的声明中成为自身的属性吗?【代码】

我需要从RubberStampServiceImpl类中调用rubberStampService的公共方法. 要从内部引用rubberStampService,我可以像这样创建一个自引用bean声明:<beans:bean id="rubberStampService" class="com.rubberly.RubberStampServiceImpl"><beans:property name="rubberStampService" ref="rubberStampService" /> </beans:bean>解决方法:听起来像一个无限递归,内存不足错误等待发生.为什么不让服务调用自己的方法并完成它?您不需要新的参...

java.lang.IllegalStateException: Failed to load ApplicationContext【代码】

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name com.alibaba.dubbo.config.RegistryConfig defined in null: Could not resolve placeholder address in string value "${address}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder address in string value "${address}"1....重复加载配置文件:一个配置文件多次引入导...

java – 运行Spring启动集成测试时无法加载ApplicationContext【代码】

我正在尝试为spring boot编写集成测试.我希望服务器在测试期间应该启动,以便我可以从测试代码连接客户端.使用java 1.7.我作为maven测试运行时遇到异常. (从控制台)java.lang.IllegalStateException: Failed to load ApplicationContextat org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)at org.springframework.test.context.suppo...

java – Spring 3 applicationContext-security-JDBC.xml有bean:bean不是bean?【代码】

有人可以告诉我在我的ApplicationContext中我必须使用bean:bean而不是bean以及如何修复它.<?xml version="1.0" encoding="UTF-8"?><beans:beans xmlns="http://www.springframework.org/schema/security"xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:jdbc="http://www.springframework.org/schema/jdbc"xsi:schemaLocation="http://www.springframewo...

java – 应该在applicationContext和dispatcherServlet中声明哪些bean【代码】

最初我在dispatcher-servlet中声明了所有bean,并且我的应用程序工作正常.我真的需要一个applicationContext.xml文件吗?解决方法:您不一定需要它,但它是分离应用程序层的首选方法: >在dispatcher-servlet.xml中只放置与web相关的东西 – 控制器,视图解析器,转换器等.>在applicationContext.xml中放入所有服务和daos,以及其他常规配置 请注意,您必须声明一个侦听器,以便spring可以加载applicationContext.xml:<listener><listener...

java – 即使使用jar也无法解析Spring ApplicationContext

我已将所有spring分发3.1.1 jar添加到构建路径,其中包括org.springframework.context-sources-3.1.1.RELEASE.jarorg.springframework.beans来源-3.1.1.RELEASE.jar. 但仍然是eclipse构建错误说,“无法解析导入org.springframework.context.ApplicationContext”. 在Spring分发3.1.1中添加所有jar之前,我逐个手动添加了jar,包括spring-context-3.0.2.RELEASE.jar和spring-beans-3.0.2.RELEASE.jar.那时ApplicationContext成功识别.但...

APPLICATION - 相关标签
LISTENER - 相关标签