广州 骏域网站建设,安卓手机app开发工具软件,推广普通话的重要意义,制作网站的工具最近由于公司项目需要#xff0c;学习了在Windows平台导出xml文件到Linux服务器上的指定目录下的方法#xff0c;#xff08;注#xff1a;这里的我的Linux是在本机上装的虚拟机#xff09;现在写下来记录一下#xff01;
1.首先是项目截图#xff1a; 2.主要是类…最近由于公司项目需要学习了在Windows平台导出xml文件到Linux服务器上的指定目录下的方法注这里的我的Linux是在本机上装的虚拟机现在写下来记录一下
1.首先是项目截图 2.主要是类
TimerAction.java package cn.gov.csrc.task.action;import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;import org.apache.struts2.convention.annotation.Action;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.output.XMLOutputter;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.context.annotation.Scope;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Controller;Controller()
Scope(prototype)
Action(TimerAction)
public class TimerAction extends QuartzJobBean {private static final String path /usr/local/datasource/zip/user.xml;Overrideprotected void executeInternal(JobExecutionContext context)throws JobExecutionException {}public void start() throws FileNotFoundException, IOException{System.out.println(计划任务开始执行......);BuildXMLDoc();System.out.println(计划任务结束执行......);}public void BuildXMLDoc() throws FileNotFoundException, IOException{Element root new Element(list);Document doc new Document(root);for(int i0;i5;i){Element elements new Element(user);elements.setAttribute(id,i);elements.addContent(new Element(name).setText(迷彩风情));elements.addContent(new Element(age).setText(24));elements.addContent(new Element(sex).setText(男));root.addContent(elements);XMLOutputter outputter new XMLOutputter();outputter.output(doc, new FileOutputStream(path));}}}3.主要的配置文件 configuration-base.xml ?xml version1.0?
beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xmlns:aophttp://www.springframework.org/schema/aopxmlns:txhttp://www.springframework.org/schema/tx xmlns:contexthttp://www.springframework.org/schema/contextxmlns:securityhttp://www.springframework.org/schema/securityxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd!-- 分散配置 --context:property-placeholder locationclasspath:jdbc.properties/!-- 组件扫描,此处的实现原理是递归扫描所有包效率较差。开发模式写法如下。后期调优可以将具体包名全部列到下面以逗号隔开 --context:component-scan base-packagecn.gov.csrc.*/!-- 配置c3p0数据源 --bean iddataSource classcom.mchange.v2.c3p0.ComboPooledDataSourceproperty namedriverClass value${jdbc.driverclass} /property namejdbcUrl value${jdbc.url} /property nameuser value${jdbc.username} /property namepassword value${jdbc.password} /property namemaxPoolSize value${c3p0.pool.size.max} /property nameminPoolSize value${c3p0.pool.size.min} /property nameinitialPoolSize value${c3p0.pool.size.ini} /property nameacquireIncrement value${c3p0.pool.size.increment} /property namemaxIdleTime value${cpool.maxIdleTime} //bean!-- 本地回话工厂bean,spring整合hibernate的核心入口 --bean idsessionFactory classorg.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean!-- 数据源 --property namedataSource refdataSource /!-- hibernate自身属性 --property namehibernatePropertiespropsprop keyhibernate.dialect${hibernate.dialect}/propprop keyhibernate.hbm2ddl.auto${hibernate.hbm2ddl.auto}/propprop keyhibernate.show_sql${hibernate.show_sql}/propprop keyhibernate.format_sqlfalse/propprop keyhibernate.temp.use_jdbc_metadata_defaultsfalse/propprop keyhibernate.cache.use_second_level_cachetrue/prop prop keyhibernate.autoReconnecttrue/prop/props/propertyproperty namepackagesToScanlistvaluecn.gov.csrc.base.systemmanager.model/value/list/property/bean!-- hibernate事务管理器,在service层上实现事务管理,达到平台无关性 --bean idtxManager classorg.springframework.orm.hibernate3.HibernateTransactionManagerproperty namesessionFactory refsessionFactory /property nameglobalRollbackOnParticipationFailure valuefalse //bean!-- 事务通知 --tx:advice idtxAdvice transaction-managertxManagertx:attributestx:method namesave* propagationREQUIRED isolationDEFAULT/tx:method nameupdate* propagationREQUIRED isolationDEFAULT/tx:method namedelete* propagationREQUIRED isolationDEFAULT/tx:method namebatch* propagationREQUIRED isolationDEFAULT/tx:method nameload* propagationREQUIRED isolationDEFAULT read-onlytrue/tx:method nameget* propagationREQUIRED isolationDEFAULT read-onlytrue/tx:method namefind* propagationREQUIRED isolationDEFAULT read-onlytrue/tx:method name* propagationREQUIRED isolationDEFAULT//tx:attributes/tx:advice!-- 任务计划 --!-- 要调用的工作 --bean idtimerAction classcn.gov.csrc.task.action.TimerAction/bean!-- 定义调用对象和调用对象的方法 --bean idtimerTask classorg.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean!-- 调用的类 --property nametargetObjectref beantimerAction//property!-- 调用类中的方法 --property nametargetMethodvaluestart/value/property!-- 作业不并发调度 --property nameconcurrent valuefalse//bean!-- 定义导出数据到xml的触发时间 --bean iddoTime classorg.springframework.scheduling.quartz.CronTriggerBeanproperty namejobDetailref beantimerTask//property!-- cron表达式 --property namecronExpressionvalue0 35 10 * * ?/value/property/bean!-- 总管理类,如果将lazy-initfalse那么容器启动就会执行调度程序 --bean idstartQuertz lazy-initfalse autowireno classorg.springframework.scheduling.quartz.SchedulerFactoryBeanproperty nametriggerslistref beandoTime//list/property/bean/beans 4.最后附上源码地址下载请点击这里
下载地址