在applicationContext.xml文件中,使用 ${xxx} 表示的是:调用某个变量,该变量的名称就是{xxx}里面的"xxx".   例如:在applicationContext.xml文件中配置数据连接池 <!-- 配置数据链接池 --> <propertyname="dataSource"> <beanclass="com.mchange.v2.c3p0.ComboPooledDataSource"…
原因还未查证: http://sunjun041640.blog.163.com/blog/static/256268322014127113844746/ 在使用spring mvc时,实际上是两个spring容器: 1,dispatcher-servlet.xml 是一个,我们的controller就在这里,所以这个里面也需要注入属性文件 org.springframework.web.servlet.DispatcherServlet 这里最终是使用WebApplicationContex…
今天在applicationContext.xml中配置sessionFactory时遇到了各种头疼的问题,现在总结一下: 1.<property name="mappingDirectoryLocations"> 如果你的xxx.hbm.xml配置文件放在了src目录的包下面,要使用mappingDirectoryLocations管理映射文件,最好在<value>标签中的文件目录前加上classpath: 如: <property name="…
我用的jeesite框架,在使用定时任务时,出现一些问题,,1.在windows上项目可以在tomcat下,运行2.在linux下项目在tomcatgh下,却出现问题: 15-Dec-2017 15:15:37.552 INFO [www.toolcoo.com-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext2017-12-15…
如下所示,直接写多个<context:property-placeholder>标签是会报错的. <context:property-placeholder location="classpath:wechat/official-account.properties" /> <context:property-placeholder location="classpath:db.properties" /> 即便是写在不同的xml…
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring…
如果采用set get方法配置bean,bean需要有set get 方法需要有无参构造函数,spring 在生成对象时候会调用get和set方法还有无参构造函数 如果采用constructor方法则不用 application代表IOC容器 级联属性 bean 引用其他 bean 用ref标签…
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <!-- driver for Derby--> <property name="driverClassName"> <value>org.apache.derby.jdbc.ClientDri…
报错如下: java.lang.NullPointerException cn.itcast.action.VisitAction.toAddPage(VisitAction.java:37) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.Del…
1.Spring中的applicationContext.xml配置错误导致的异常 异常信息: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ssm.service.BTestService.getPhoneKey at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:2…
问题描述: 在配置spring的applicationContext.xml中的默认事务管理器的时候可能会出现这样的错误: Error occured processing XML 'org/springframework/transaction/interceptor/TransactionInterceptor'. See Error Log for more details 以下是xml配置: <bean id="transactionManager" class=&quo…
在applicationContext.xml中配置如下: 通过以下property标签中给定name属性value属性及对应的值,来将domain包下所有实体类设置别名. 在xxxDao.xml中 未配置别名前:resultType="cn.xxx.xxx.domain.Order" 配置别名后:resultType="Order"…
Spring配置文件——复制粘贴即用 为了以后兼容SSM框架,直接创建Maven Project,包结构如下图. pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 htt…
在java框架这个话题,前几篇文章是基于搭建ssm项目框架,以及web.xml的配置讲解,本篇主要就ssm框架的其他配置文件进行深入讲解,他们分别是:1.application-context.xml:2.spring-mvc.xml. 回顾一下application-context.xml和spring-mvc.xml在web.xml中的配置是怎样的. (0)前沿 1.application-context.xml是全局的,应用于多个serverlet,配合listener一起使用,web.x…
在刚学习SpringMVC框架整合时,你也许会产生疑问为什么Spring.xml和SpringMVC.xml中都有注解过滤. <context:component-scan base-package="myproject"> 和<context:component-scan base-package="myproject.controller" /> 在这里有一个比较有意思的问题,初学者也会产生困惑,那么他究竟有何不同?我思考和查询很久,话不…
项目中经常会用到配置文件,定义成properties的形式比较常见,为了方便使用一般在spring配置文件中做如下配置: <context:property-placeholder ignore-unresolvable="true" location="classpath*:/application.properties" /> 这样在程序代码中直接用@Value("${name}")就能直接取到properties文件中定义的变量…
一.spring中如何使用多个xml配置文件 1.在web.xml中定义contextConfigLocation参数,Spring会使用这个参数去加载所有逗号分隔的xml文件,如果没有这个参数,spring会默认加载WEB-INF/applicationContext.xml文件(若没有,要新建一个). 例如: <context-param> <param-name>contextConfigLocation</param-name> <param-value&…
在搭建 spring mvc 的框架时,会有2个配置文件必不可少: spring-servlet.xml 和applicationContext.xml.第一次接触spring mvc的工程师可能会对这2个文件的感到疑惑, 下面会对这个两个文件的配置功能展开阐述: spring-servlet.xml 如何加载? 顾名思义,是基于servlet的,如果在一个工程A(下面全部命名为A)的结构是类似于web,service,dao的分层,此配置作用于web层会更合理,在工程A的web.xml文件中,…
这里简单介绍一下spring的配置文件applicationContext.xml中的一些配置的作用. <context:component-scan base-package=""/> 表示启动spring的组件扫描功能(从spring2.5版本开始).即扫描base-package包或者子包下面的Java文件,如果扫描到有@controller.@Service.@Repository.@Component等注解的java类,就会将这些bean注册到工厂中.还可以使用分…
上一篇SpringMVC之web.xml让我们了解到配置一个web项目的时候,怎样做基础的DispatcherServlet相关配置.作为SpringMVC上手的第一步.而application-context.xml则让我们了解到怎样将数据库信息载入到项目中,包括重要的作用库连接信息.sqlSessionFactory.事务等关键因素. ①.xml内容 <?xml version="1.0" encoding="UTF-8"?> <beans x…
在构建springmvc+mybatis项目时,更常用的方式是采用web.xml来配置,而且一般情况下会在web.xml中使用ContextLoaderListener加载applicationContext-*.xml,在DispatcherServlet中配置${servlet-name}-servlet.xml. 但是实际上除了采用xml方式,在springmvc+mybatis项目中也可以采用纯代码+注解方式来替换web.xml.applicationContext-*.xml.${se…
记录一下: org.springframework.context.support.AbstractApplicationContext prepareRefresh Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@7cef4e59: startup date [Fri Sep 30 09:33:28 CST 2016]; root of context hierarchy org.spr…
Spring中加载ApplicationContext.xml文件的方式 原文:http://blog.csdn.net/snowjlz/article/details/8158560 1.利用ClassPathXmlApplicationContext,可以从classpath中读取XML文件 (1)    ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml")…
<bean id="propertyConfigurer" class="com.****.framework.core.SpringPropertiesUtil" lazy-init="false"> <property name="locations"> <list> <value>classpath:config/sys.properties</value> &…
一直搞不明白两者的区别. 如果使用了SpringMVC,事实上,bean的配置完全可以在xxx-servlet.xml中进行配置.为什么需要applicationContext.xml?一定必须? 一. 因为直接使用了SpringMVC,所以之前一直不明白xxx-servlet.xml和applicationContext.xml是如何区别的,其实如果直接使用SpringMVC是可以不添加applicationContext.xml文件的. 使用applicationContext.xml文件时…
2011-11-08 16:29 web.xml中配置Spring中applicationContext.xml的方式 使用web.xml方式加载Spring时,获取Spring applicationContext.xml的方式 1.servlet方式加载: [web.xml] <servlet>    <servlet-name>dispatcherServlet</servlet-name>    <servlet-class>org.springfr…
一.首先写一下代码结构. 二.再看web.xml中的配置情况. <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http:…
当你的Spring IOC 容器忘记配到web.xml 文件中时,启动服务器就会报错. 部分错误如下: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.zcd.linkage.services.LinkageService' available: expected at least 1 bean which qualifies a…
在applicationContext.xml文件中的设置为: <beans> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" />…
一.博主在学习到整合ssm框架的时候,遇到一个奇葩的问题就是将 事务的控制 ,写在在applicationContext.xml文件中不起作用,在事务控制的方法中,即使出现了异常,但是事务不会回滚的坑,按道理说,我们配置了事务,在异常发生是,运行时期的异常被我们的框架捕获到,就会为我们做出回滚的操作,但是就是没有,比如博主写的一个简单的转帐的事务,第一个账户的钱被扣除了,但是在执行完扣钱之后发生了异常但是我们在数据库中却发现,钱仍然被扣了, 博主也试过网上的大多数的方法,都是只说原因,并不能解决…