Spring写临时配置文件件时不提示怎么办

eclipse开发spring配置文件xml代码不提示的解决方法
  这个对于很多xml格式的配置文件编辑很有帮助,以spring配置文件为例:
  myeclipse的童鞋进入:window -& Preferences-& MyEclipse -&
Editors -& XML -&XML Catalog
  eclipse的童鞋进入:window -& Preferences-& XML -&XML
  或者再接再 Preferences 里面的搜索框输入xml就能看到其下面有 XML Catalog 选中
  选择:选中“User Specified Entries”,点击“Add...”按钮
  填入:
  location: 选择本地文件系统上 spring-beans-2.5.xsd 文件
(我的在D:\ssh\spring\spring-framework-2.5.6\dist\resources\spring-beans-2.5.xsd)
  Key Type: 选择URI
  点击确定
  将spring配置文件关闭再重新打开即可。可以使用XML Editor打开这些xml文件。
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。博客分类:
1,Spring使用property文件作为配置源
工程中难免出现一些需要每次部署都需要配置的参数,如数据源连接参数等,测试环境跟实际运行环境是不一样的。
使用spring框架的话,这些参数可能独立分布在不同的springContex配置文件里面。
可以考虑将这些参数独立到一个配置文件并可以让spring方便加载注入。可选的一个方案是使用java的property文件,将所有的配置参数都写到property文件里面,使用${key}来在spring配置文件里面得到这个参数。
property文件global-config-file.properties:
#FOR dataSource
jdbc.dataSource.url=jdbc:postgresql://192.168.1.118:5432/DB_name
jdbc.dataSource.username=postgres
jdbc.dataSource.password=123
示例配置的是数据源参数。
之后在springContext的配置文件中,加入下面代码,:
&bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&
&property name="ignoreUnresolvablePlaceholders" value="true" /&
&property name="location" value="classpath:global-config-file.properties"/&
即引入PropertyPlaceholderConfigurer来读取property配置文件,spring框架会从其那里获取到需要的配置参数。
之后再用${key}的格式取代你数据源配置参数:
&bean id="myBatisDataSource" class="mons.dbcp.BasicDataSource"&
&property name="driverClassName" value="org.postgresql.Driver"&
&/property&
&property name="url"
value="${jdbc.dataSource.url}"&
&/property&
&property name="username" value="${jdbc.dataSource.username}"&&/property&
&property name="password" value="${jdbc.dataSource.password}"&&/property&
例如:${jdbc.dataSourcurl}:框架会将global-config-file.properties读到jdbc.dataSource.url的值“jdbc:postgresql://192.168.1.118:5432/DB_name”填入${jdbc.dataSource.url}所在的位置。
2,将property配置文件与工程分离(独立到服务器中)
为什么想到要这样做呢?
这是在实际开发部署中,每次将工程打包部署到服务器,都需要在服务器端修改工程的配置项(如数据源等),感觉很麻烦。
如果工程优先读取放置在服务器上的配置文件,没有此配置文件才从工程目录里面读取,那样就可以将只在服务器存放一份配置文件并修改成与服务器运行环境一致,今后部署即可不用每次都修改工程配置文件了。
2.1 做法:
刚才我们在第1点添加了一个propertyConfigurer,现将其改名为“propertyConfigurer2”,并添加一个“propertyConfigurer1”,两者配置为:
&bean id="propertyConfigurer1"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&
&property name="order" value="1"/&
&property name="ignoreResourceNotFound" value="true"/&
&property name="ignoreUnresolvablePlaceholders" value="true" /&
&property name="location" value="file:C:/tempSys/config/global-config-file.properties"/&
&bean id="propertyConfigurer2"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&
&property name="order" value="2"/&
&property name="ignoreUnresolvablePlaceholders" value="true" /&
&property name="location" value="classpath:global-config-file.properties"/&
order属性表示加载顺序,这种配置表示先加载propertyConfigurer1,在加载propertyConfigurer2,两者配置文件中有同样的参数,后加载的参数不会覆盖先加载的。
propertyConfigurer1需要添加一个 &property name="ignoreResourceNotFound" value="true"/&属性,表示当找不到这个配置文件时,则跳过,这样就不会抛出FileNotFoundException了。
这样配置之后,工程会在启动时,首先检查C:/tempSys/config/global-config-file.properties是否存在,如果存在则加载器配置,随后再加载项目目录下的global-config-file.properties;如果不存在,则直接加载项目目录下的global-config-file.properties。
这样做不单可将配置与开发环境分离出来,避免每次部署时繁琐的配置修改工作。同时这也提高了系统部署时的安全性,比如,实际运行的正式数据库账户密码信息将是十分机密的信息,由运维人员保管维护,可能对开发人员都不能公开(开发人员只知道开发测试数据库的信息),将这些信息直接配置在服务器上,服务器也由运维人员进行管理,这样可以减少机密信息的知晓人群,提高安全性。
RookieDong
浏览: 42741 次
来自: 汕头
很有用的说 谢谢哦
不客气地收下啦 谢谢
Good, slave my problem
effort_fan 写道谢谢,很有用,借鉴了
不用客气啦,自 ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'编写spring配置文件时,不能出现帮助信息(eclipse中xml catalog导入dtd与xsd)_文档下载
编写spring配置文件时,不能出现帮助信息(eclipse中xml catalog导入dtd与xsd)
用myeclipse,编写spring配置文件时,不能出现帮助信息(eclipse中xml catalog导入dtd与xsd)
编写spring配置文件时,不能出现帮助信息(eclipse中xml catalog导入dtd与
博客分类:
由于spring的schema文件位于网络上,如果机器不能连接到网络,那么在编写配置信息时候就无法出现提示信息,解决方法有两种:
1。让机器上网,eclipse会自动从网络上下载schema文件并缓存在硬盘上。
2。手动添加schema文件,方法如下:
windwos-&preferences-&myeclipse-&files and editors-&xml-&xmlcatalog
点&add&,在出现的窗口中的Key Type中选择URI,在location中选&File system&,然后在spring解压目录的dist/resources目录中选择spring-beans-2.5.xsd,回到设置窗口的时候不要急着关闭窗口,应把窗口中的Key Type改为Schema location,Key改为/schema/beans/spring-beans-2.5.xsd
&!-------------------------others-----------------------------------&
Xml catalog方便struts.xml,applicationContext.xml的创建
导入spring【schema】
\spring 3.0\org\springframework\beans\factory\xml\spring-beans-3.0.xsd
\spring 3.0\org\springframework\context\config\spring-context-2.5.xsd
&beans xmlns=&/schema/beans&
xmlns:xsi=&/2001/XMLSchema-instance&
xmlns:context=&/schema/context&
xmlns:aop=&/schema/aop&
xmlns:tx=&/schema/tx&
xsi:schemaLocation=&/schema/beans
/schema/beans/spring-beans.xsd
/schema/context
/schema/context/spring-context-2.5.xsd
/schema/aop
/schema/aop/spring-aop-2.0.xsd
Eclipse手工导入Xml Catalog的方法_计算机软件及应用_...xsd 文件(即 Spring 的文档验证文件)时,keytype ...打开 dtd 文件复制出文档类型中的信息即可, 需要注意...开发jms时,遇到xml配置文件的命名空间DTD定义错误_计算机...2.0.xsd http://www.springframework.org/schema/...eclipse 的 xml catalog 配置的时候,也可以不 用...Eclipse 中XML文件处理插件Rinzo_计算机软件及应用_IT...? ? 自动显示 DTD 或 Schema 里的标签和属性 ...编写spring配置文件时,不... 2页 免费 XML文件处理...不导入运行 Tomcat 时 候可能会出现异常。 commons-...spring -2.5.xsd http://www.springframework.org/...eclipse 中配置提示必备文件 配置 xml catalog ibatis...Maven项目单独建立和spring项目中的使用使用Eclipse ...app_2_5.xsd& version=&2.5& & &!-- 区分...&/web-app& 4.2 编写 Spring 配置文件 dispatcher-...
2.5.xsd&& &/beans& 该配置模板可以从 Spring 的...文件时, 四:编写 Spring 文件时,不能出现帮助信息...&xml-&xmlcatalog 点& add&,在出现的窗口中的 ....jar 编写spring配置文件时,不能出现帮助信息 ?...&xml&xmlcatalog-&点&add& spring的配置文件模版 ...DTD 3.0//EN& &http://hibernate.sourceforge.net...编写spring配置文件时,不能出现帮助信息由于spring的...&xml&xmlcatalog 点&add&,在出现的窗口中的Key ...2.5.xsd,回到设置窗口的时候不要急着关闭窗口,应把...暂无评价0人阅读0次下载举报文档 Eclipse中Apache Ant编写build.xml的自动提示 ANT DTD_计算机软件及应用_IT/计算机_专业资料。今日...2.让eclipse对spring的配置文件有提示功能 点击window...&搜索xmlcatalog,打开,点击add,Key Type中选择URI,...2.5.xsd& default-lazy-init=&false&& 5.定义...博客分类:
由于spring的schema文件位于网络上,如果机器不能连接到网络,那么在编写配置信息时候就无法出现提示信息,解决方法有两种:
1。让机器上网,eclipse会自动从网络上下载schema文件并缓存在硬盘上。
2。手动添加schema文件,方法如下:
windwos-&preferences-&myeclipse-&files and editors-&xml-&xmlcatalog
点"add",在出现的窗口中的Key Type中选择URI,在location中选"File system",然后在spring解压目录的dist/resources目录中选择spring-beans-2.5.xsd,回到设置窗口的时候不要急着关闭窗口,应把窗口中的Key Type改为Schema location,Key改为http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
&!-------------------------others-----------------------------------&
Xml catalog方便struts.xml,applicationContext.xml的创建
导入spring【schema】
\spring 3.0\org\springframework\beans\factory\xml\spring-beans-3.0.xsd
\spring 3.0\org\springframework\context\config\spring-context-2.5.xsd
&beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
导入struts(对应的keyid从dtd文件中查找)
struts-2.0.dtd -&struts-2.2.1\lib\struts2-core-2.2.2.1目录下
&&&&&&&&&&&&&&&& struts-2.2.1\src\core\src\main\resources目录下也有
&&&&&&&&&&&&&&&&
xwork-2.0.dtd& -&struts-2.2.1\src\xwork-core\src\main\resource目录下
xwork-validator-1.0.3.dtd& -&struts-2.2.1\src\xwork-core\src\main\resource目录下
浏览: 52133 次
来自: 深圳
http://www.eclipse.org/birt/pho ...
博主,你好,请问一下你有birt2.5.2的下载地址吗?有的话 ...
你应该把jad.exe、net.sf.jadclipse_3 ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'在eclipse 中 如何添加spring框架 怎么写配置文件 不是myeclipse
全部答案(共1个回答)
了,有点复杂
JAVA 环境配置
第一步:下载j2sdk:到sun官方站点( )下载j2sdk,注意下载版本为Windows Offline Installation的SDK...
My Eclipse是一个JAVA程序开发工具,至于你说的HTML, Struts, JSF, CSS, Javascript, SQL, Hibernate还...
下载更新 PlantUML Eclipse 插件,打开 Eclipse,Help-& Install new software...。
填入相应的 URL:
不是Structs是struts
用myeclipse,用它部署web项目,启服务器很方便。 它有一个add struts/hibernate capabili...
PROPAGATION_REQUIRED,readOnly
PROPAGATION_REQUIRED
PROPAGATION_REQUIR...
答: 没关系的,只需要退税单就行。
答: 这个要设计到JNI的开发,就是用Java来调用C语言的函数库,还要编写缓冲器来解决传输问题,还有就是网络协议一定要了解,做的时候要用多线程来控制你所有的缓冲器,...
答: 所谓的网络编程,不论c还是java,本质上都是通过socket进行数据传输;
一般情况下可以使用的传输协议有tcp、udp、ftp等等,这些协议为网络变成提供基...
大家还关注
确定举报此问题
举报原因(必选):
广告或垃圾信息
激进时政或意识形态话题
不雅词句或人身攻击
侵犯他人隐私
其它违法和不良信息
报告,这不是个问题
报告原因(必选):
这不是个问题
这个问题分类似乎错了
这个不是我熟悉的地区
相关问答:123456789101112131415

我要回帖

更多关于 linux 时区配置文件 的文章

 

随机推荐