circular placeholdecircular referencee怎么解决

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
您的访问请求被拒绝 403 Forbidden - ITeye技术社区
您的访问请求被拒绝
亲爱的会员,您的IP地址所在网段被ITeye拒绝服务,这可能是以下两种情况导致:
一、您所在的网段内有网络爬虫大量抓取ITeye网页,为保证其他人流畅的访问ITeye,该网段被ITeye拒绝
二、您通过某个代理服务器访问ITeye网站,该代理服务器被网络爬虫利用,大量抓取ITeye网页
请您点击按钮解除封锁&在eclipse3.4中部署appfuse详解 - mse - 博客园
posts - 5, comments - 4, trackbacks - 0, articles - 24
转贴队友的部署appfuse经验,thx our team member:
部署前准备
1,安装apache-tomcat-6.0.182,下载ftp中的eclipse-jee,(由于在myeclipse7.0中的部署还是有问题,所以我暂时先用eclipse)
下载appfuse代码
我们假设你已经把代码下载到你本地目录上
1,在项目当前的命令行目录中运行 mvn eclipse:eclipse 把项目转换成eclipse项目2,在eclipse中导入项目file-&import-&existing projects into workspace3,修改项目java build path,点击项目属性-&java build path-&source-&src/main/webapp,修改output folder为demo/target/classes,其中demo是你项目的名称
1,新建一个server, 在new-&Server-&server2,选择tomcat6.0 server3,在add and remove projectes窗口中添加你要部署的项目4,publish项目,在server窗口中选择要部署项目,右键点击publish
可能遇到的问题
在这里你会遇到修改org.ponent配置文件后,项目无法publish的问题,如果遇到这种问题,请参考后面的补充内容
5,运行项目
OK, 如果你能到达这里,恭喜,你已经成功一半了,这是你会发现tomcat服务器爆出如下异常:Invalid bean definition with name 'dataSource' defined in class path resource : Circular placeholder reference 'jdbc.driverClassName' in property definitions这是由于在jdbc.properties文件中的jdbc.driverClassName没有被替代为jdbc driver的问题,由于有另一篇文章说明了解决方案,我就不再重复说了,在这里请大家参考下面这篇文章:
1,关于那篇文章中提及的exclude的操作,具体在项目属性-&java build path-&Source-&src/main/resource下面的exclude添加jdbc.properties2,在那篇文章中提及的org.ponent配置文件位置在demo\.settings文件夹中3,你可能会遇到这如下问题:
部署tomcat server内容为空
修改配置文件后启动tomcat server却发现tomcat部署目录(在我的机器中为:E:\Project\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps)中没有生成相应的demo文件夹。暂时解决方案:不修改org.ponent配置文件,采用原来的配置文件部署tomcat服务其,然后直接复制target/classes与src/webapp里的东西到tomcat的demo中相应目录中去。由于我们在原项目中对这些properites文件设置了exclude,由此就算我们重新publish项目也不会重新替换这些文件4238人阅读
j2ee(81)
spring(35)
在第二编对BeanFactory的分析中,我们老能看见BeanFactoyPostProcessor的身影,那么在这一节中,我们来详细的讨论一下BeanFactoryPostProcessor的代码结构,从中学习他的优秀之处;BeanFactoryPostProcessor能够修改bean配置文件中的bean的定义;使得我们能够进行一些额外的处理;在spring中,我们几乎不用自己扩展这个接口,因为他内置了很多实现,但是,我们从原理上和代码上来分析其功能的实现;一下是他的类图实现:拿PropertyPlaceholderConfigurer举例;PropertyPlaceholderConfigurer的功能是这样的,我们在配置文件中配置如下Bean:
&id="PropertyPlaceholderConfigurer"&class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
&name="order"1
&name="locations"
&userinfo.properties
&id="user"&class="org.test.UserInfo"
&name="order"
&name="order"
userinfo.properties:db.username:scottdb.password:tiger然后在ApplicationContext下面会自动调用这个PostP把模板方法1:mergeProperties()如下:protected Properties mergeProperties() throws IOException {&&& &&& Properties result = new Properties();&&& &&& if (this.localOverride) {&&& &&& &&& // Load properties from file upfront, to let local properties override.&&& &&& &&& loadProperties(result);&&& &&& }&&& &&& if (this.localProperties != null) {&&& &&& &&& for (int i = 0; i & this.localProperties. i++) {&&& &&& &&& &&& Properties props = this.localProperties[i];&&& &&& &&& &&& // Use propertyNames enumeration to also catch default properties.&&& &&& &&& &&& for (Enumeration en = props.propertyNames(); en.hasMoreElements();) {&&& &&& &&& &&& &&& String key = (String) en.nextElement();&&& &&& &&& &&& &&& result.setProperty(key, props.getProperty(key));&&& &&& &&& &&& }&&& &&& &&& }&&& &&& }&&& &&& if (!this.localOverride) {&&& &&& &&& // Load properties from file afterwards, to let those properties override.&&& &&& &&& loadProperties(result);&&& &&& }&&& &&&&&& }在这个方法中,将加载你在构造bean的时候传入的properties值,然后存储到这个PostProcessor中,方便覆盖bean定义的元数据,如${db.username}等等;模板方法processProperties被推到子类实现了:protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)&&& &&& &&& throws BeansException {&&&&&&& //构造一个BeanDefinition访问器(前一节已经分析过),是其内部类:&&& &&& BeanDefinitionVisitor visitor = new PlaceholderResolvingBeanDefinitionVisitor(props);&&&&&&& //得到所有beanName&&& &&& String[] beanNames = beanFactoryToProcess.getBeanDefinitionNames();&&& &&& for (int i = 0; i & beanNames. i++) {&&& &&& &&& // Check that we're not parsing our own bean definition,&&& &&& &&& // to avoid failing on unresolvable placeholders in properties file locations.&&& &&& &&& if (!(beanNames[i].equals(this.beanName) && beanFactoryToProcess.equals(this.beanFactory))) {&&& &&& &&& &&& BeanDefinition bd = beanFactoryToProcess.getBeanDefinition(beanNames[i]);&&& &&& &&& &&& try {&&&&&&&&&&&&&&&&&&& //在这段代码中会遍历所有的Bean定义的带来${}的属性,包括map ,list,String等等;&&& &&& &&& &&& &&& visitor.visitBeanDefinition(bd);&&& &&& &&& &&& }&&& &&& &&& &&& catch (BeanDefinitionStoreException ex) {&&& &&& &&& &&& &&& throw new BeanDefinitionStoreException(bd.getResourceDescription(), beanNames[i], ex.getMessage());&&& &&& &&& &&& }&&& &&& &&& }&&& &&& }&&& }内部的BeanDefinition访问器:private class PlaceholderResolvingBeanDefinitionVisitor extends BeanDefinitionVisitor {&&& &&& private final P&&& &&& public PlaceholderResolvingBeanDefinitionVisitor(Properties props) {&&& &&& &&& this.props =&&& &&& }&&& &&& protected String resolveStringValue(String strVal) throws BeansException {&&& &&& &&& return parseStringValue(strVal, this.props, new HashSet());&&& &&& }&&& }在访问器中visitBeanDefinition(bd)会遍历此BeanDefinition的proerty,constructor等等可以设置${}的地方例如propertiy:protected void visitPropertyValues(MutablePropertyValues pvs) {&&& &&& PropertyValue[] pvArray = pvs.getPropertyValues();&&& &&& for (int i = 0; i & pvArray. i++) {&&& &&& &&& PropertyValue pv = pvArray[i];&&&&&&&&&&& //分别解决每个属性字段的解析;&&& &&& &&& Object newVal = resolveValue(pv.getValue());&&& &&& &&& if (!ObjectUtils.nullSafeEquals(newVal, pv.getValue())) {&&& &&& &&& &&& pvs.addPropertyValue(pv.getName(), newVal);&&& &&& &&& }&&& &&& }&&& }如何解析,是暴露到子类中去进行的如PropertyPlaceholderConfigurer是对${}进行外部文件的替换,我们也可以自己实现别的替换方式,如:****替换位"corey",很无聊吧: -&;resolveStringValue((String) value);:protected Object resolveValue(Object value) {&&& &&& if (value instanceof BeanDefinition) {&&& &&& &&& visitBeanDefinition((BeanDefinition) value);&&& &&& }&&& &&& else if (value instanceof BeanDefinitionHolder) {&&& &&& &&& visitBeanDefinition(((BeanDefinitionHolder) value).getBeanDefinition());&&& &&& }&&& &&& else if (value instanceof RuntimeBeanReference) {&&&&& RuntimeBeanReference ref = (RuntimeBeanReference)&&&&& String newBeanName = resolveStringValue(ref.getBeanName());&&& &&& &&& if (!newBeanName.equals(ref.getBeanName())) {&&& &&& &&& &&& return new RuntimeBeanReference(newBeanName);&&& &&& &&& }&&& &&& }&&& &&& else if (value instanceof List) {&&& &&& &&& visitList((List) value);&&& &&& }&&& &&& else if (value instanceof Set) {&&& &&& &&& visitSet((Set) value);&&& &&& }&&& &&& else if (value instanceof Map) {&&& &&& &&& visitMap((Map) value);&&& &&& }&&& &&& else if (value instanceof TypedStringValue) {&&& &&& &&& TypedStringValue typedStringValue = (TypedStringValue)&&& &&& &&& String visitdString = resolveStringValue(typedStringValue.getValue());&&& &&& &&& typedStringValue.setValue(visitdString);&&& &&& }&&& &&& else if (value instanceof String) {&&& &&& &&& return resolveStringValue((String) value);&&& &&& }&&& &&&&&& }那${userName}举例:在PropertyPlaceholderConfigurer中:protected String parseStringValue(String strVal, Properties props, Set visitedPlaceholders)&&& &&& throws BeanDefinitionStoreException {&&& &&& StringBuffer buf = new StringBuffer(strVal);&&&&&&& &&&&&&& //提取出${}中间的字符串,&&& &&& int startIndex = strVal.indexOf(this.placeholderPrefix);&&& &&& while (startIndex != -1) {&&& &&& &&& int endIndex = buf.toString().indexOf(&&& &&& &&& &&& this.placeholderSuffix, startIndex + this.placeholderPrefix.length());&&& &&& &&& if (endIndex != -1) {&&& &&& &&& &&& String placeholder = buf.substring(startIndex + this.placeholderPrefix.length(), endIndex);&&& &&& &&& &&& if (!visitedPlaceholders.add(placeholder)) {&&& &&& &&& &&& &&& throw new BeanDefinitionStoreException(&&& &&& &&& &&& &&& &&& &&& "Circular placeholder reference '" + placeholder + "' in property definitions");&&& &&& &&& &&& }&&&&&&&&&&&&&&& //用System.getEnv和外部的properties文件替代了${}中间的值&&& &&& &&& &&& String propVal = resolvePlaceholder(placeholder, props, this.systemPropertiesMode);&&& &&& &&& &&& if (propVal != null) {&&& &&& &&& &&& &&& // Recursive invocation, parsing placeholders contained in the&&& &&& &&& &&& &&& // previously resolved placeholder value.&&&&&&&&&&&&&&& //嵌套执行;直至无法解析;&&& &&& &&& &&& &&& propVal = parseStringValue(propVal, props, visitedPlaceholders);&&& &&& &&& &&& &&& buf.replace(startIndex, endIndex + this.placeholderSuffix.length(), propVal);&&& &&& &&& &&& &&& if (logger.isDebugEnabled()) {&&& &&& &&& &&& &&& &&& logger.debug("Resolved placeholder '" + placeholder + "' to value [" + propVal + "]");&&& &&& &&& &&& &&& }&&& &&& &&& &&& &&& startIndex = buf.toString().indexOf(this.placeholderPrefix, startIndex + propVal.length());&&& &&& &&& &&& }&&& &&& &&& &&& else if (this.ignoreUnresolvablePlaceholders) {&&& &&& &&& &&& &&& // Proceed with unprocessed value.&&& &&& &&& &&& &&& startIndex = buf.toString().indexOf(this.placeholderPrefix, endIndex + this.placeholderSuffix.length());&&& &&& &&& &&& }&&& &&& &&& &&& else {&&& &&& &&& &&& &&& throw new BeanDefinitionStoreException("Could not resolve placeholder '" + placeholder + "'");&&& &&& &&& &&& }&&& &&& &&& &&& visitedPlaceholders.remove(placeholder);&&& &&& &&& }&&& &&& &&& else {&&& &&& &&& &&& startIndex = -1;&&& &&& &&& }&&& &&& }&&& &&& return buf.toString();&&& }在这里,模板模式再一次展现了他的魅力,我想在这里讨论一下:PropertiesLoaderSupport和PropertyResourceConfigurer的关系,我们看见PropertiesLoaderSupport提供了properties文件的加载,在这里继承抽象类PropertiesLoaderSupport其实是达到与复用;我们继承一个抽象类的原因有两个:1):与其它类功能方法之间的复用(比如这里的PropertiesLoaderSupport);而不是从分类学上面属于一类,这样的抽象类属于工具类;这里的功能复用,有两种手段可以实现,一种是组合,一种是继承;2):抽象类中约定类流程,把算法的具体实现暴露给子类;
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:1818931次
积分:23798
积分:23798
排名:第205名
原创:559篇
转载:290篇
评论:296条
(1)(7)(3)(4)(5)(13)(7)(14)(37)(2)(27)(16)(2)(6)(10)(1)(1)(6)(9)(10)(2)(1)(12)(12)(3)(9)(14)(5)(2)(4)(4)(22)(12)(9)(3)(10)(19)(28)(13)(20)(8)(16)(21)(12)(36)(20)(32)(11)(7)(4)(11)(2)(2)(4)(32)(31)(15)(21)(8)(10)(36)(24)(28)(44)(7)(7)(8)(5)(1)(1)(7)Konto zosta?o zawieszone z powodu przekroczenia terminu wniesienia op?aty abonamentowej.

我要回帖

更多关于 circular dichroism 的文章

 

随机推荐