个:
一、在本机开启Web服务(如Tomcat等等),并设置端口为80,然后根据DTD 的目录结构建立相应的结构,并把DTD文件放进去。然后在hosts文件里把本机的地址映射到相应的DTD指定的网站去,如:
127.0.0.1// www.springframework.org
这样打开XML文件时就会在本机寻找DTD文件进行验证,速度就快很多了J
二、打开XMLBuddy插件的安装目录,并找到其中的cache目录,比如:
%ECLIPSE_HOME%\PlugInsNew\xmlbuddy\eclipse\plugins\com.objfac.xmleditor_2.0.72\.cache
打开meta.xml文件,一看就知道怎么处理了吧,如法炮制,选把DTD文件拷贝到这个cache目录里,再增加内容到meta.xml里来,比如:
<file>
<pub>-//SPRING//DTD BEAN//EN</pub>
<abs>http://www.springframework.org/dtd/spring-beans.dtd</abs>
<rel>spring-beans.dtd</rel>
</file>
要增加其它的DTD文件方法类似,不断地增加说明与DTD文件即可。
于是在编辑XML文件时就会有相关的提示及错误提示信息,可以减少一些书写XML文件时发生的低级错误了。
测试与运行
先建立一个Log4J的配置文件log4j.properties,内容如下
# Set root logger level to ERROR and its only appender to R.
log4j.rootLogger = INFO,R
# R is set to be a DailyRollingFileAppender.
log4j.appender.R = org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File = Application.log
log4j.appender.R.DatePattern = yyyy-MM-dd''.log''
log4j.appender.R.layout = org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n
Eclipse插件之Spring IDE(16)
时间:2010-12-31 BEA 俞黎敏
再创建一个ServiceFactory.java静态类,用来做单元测试方便一些
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.access.BeanFactoryLocator;
import org.springframework.beans.factory.access.BeanFactoryReference;
import org.springframework.beans.factory.access.SingletonBeanFactoryLocator;
public final class ServiceFactory
{
private static BeanFactoryLocator bfLocator = null;
private static BeanFactoryReference bfReference = null;
private static BeanFactory factory = null;
static
{
bfLocator = SingletonBeanFactoryLocator.getInstance();
bfReference = bfLocator.useBeanFactory("beanFactory");
factory = bfReference.getFactory();
}
private ServiceFactory()
{
super();
}
public static Object getBeanByName(final String beanName)
{
return factory.getBean(beanName);
}
}
做成静态的这样我们可以ServiceFactory .getBeanByName(“beanname”)就可以得到相应的bean了。
测试类SpringIDETest.java代码如下:
import junit.framework.TestCase;
public class SpringIDETest extends TestCase
{
private IHelloWorld helloWorld = null;
private ISpringDemo springDemo = null;
private final static String hello1 = "Hello World HelloWorld1";
private final static String hello2 = "Hello World HelloWorld2";
private final static String helloset = "Spring IDE Setter";
private final static String hellocon = "Spring IDE Constructor";
public void testSpringBeans()
{
helloWorld = (IHelloWorld)ServiceFactory.getBeanByName("helloWorld1");
assertEqua
|