草庐IT

java - Spring MVC 3.2.8 : FtpInboundFileSynchronizer

coder 2023-05-11 原文

我有一个基于 Spring Web model-view-controller (Spring MVC 3.2.8) 的应用程序,我想使用 FTP SessionFactory 的默认实现来与 FTP 集成。

我有这段代码

private void performImport() throws Exception {

    String fileNamePattern="*.txt";

    ftpInboundFileSynchronizer = new FtpInboundFileSynchronizer(myFtpSessionFactory );
            ((FtpInboundFileSynchronizer) ftpInboundFileSynchronizer).setFilter(new FtpSimplePatternFileListFilter(fileNamePattern));

    ftpInboundFileSynchronizer.setRemoteDirectory(remoteDirectory);

    deleteLocalFiles();

    System.out.println ("before synchronize");

    ftpInboundFileSynchronizer.synchronizeToLocalDirectory(localDirectory);

    System.out.println ("after synchronize");
}

这是我在控制台中看到的:

before synchronize
after synchronize

在 FTP 中,我有一个 test.txt 文件,但该文件未传输,并且我没有错误/异常

我也尝试过使用 fileNamePattern="*.*"; 但它也不起作用

这是我的配置文件:

@Configuration
@PropertySource("classpath:/config/application.properties")
public class FtpConfiguration {

    @Autowired
    private SessionFactory myFtpSessionFactory;

    @Bean
    @Scope(value="step")
    public FtpGetRemoteFilesTasklet myFtpGetRemoteFilesTasklet()
    {
        FtpGetRemoteFilesTasklet  ftpTasklet = new FtpGetRemoteFilesTasklet();
        ftpTasklet.setRetryIfNotFound(true);
        ftpTasklet.setDownloadFileAttempts(3);
        ftpTasklet.setRetryIntervalMilliseconds(10000);
        ftpTasklet.setFileNamePattern("README");
        //ftpTasklet.setFileNamePattern("TestFile");
        ftpTasklet.setRemoteDirectory("/");
        ftpTasklet.setLocalDirectory(new File(System.getProperty("java.io.tmpdir")));
        ftpTasklet.setSessionFactory(myFtpSessionFactory);

        return ftpTasklet;
    }

    @Bean   
    public SessionFactory myFtpSessionFactory()
    {
        DefaultFtpSessionFactory ftpSessionFactory = new DefaultFtpSessionFactory();
        ftpSessionFactory.setHost("myhost.com");
        ftpSessionFactory.setClientMode(0);
        ftpSessionFactory.setFileType(FTP.ASCII_FILE_TYPE);
        ftpSessionFactory.setPort(1029);
        ftpSessionFactory.setUsername("some_username");
        ftpSessionFactory.setPassword("really-private-password");

        return ftpSessionFactory;
    }
}

并且服务器日志文件中没有与 FTP 相关的内容

(self-tuning)'> <<WLS Kernel>> <> <> <1500554849537> <BEA-101341> <ecolabelEar: Class file up-to-date for JSP: /WEB-INF/jsp/template/LHheader.jsp> 
    ####<20-Jul-2017 14:47:29 o'clock CEST> <Info> <HTTP> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554849554> <BEA-101341> <ecolabelEar: Class file up-to-date for JSP: /WEB-INF/jsp/template/popupHeader.jsp> 
    ####<20-Jul-2017 14:47:29 o'clock CEST> <Info> <HTTP> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554849575> <BEA-101341> <ecolabelEar: Class file up-to-date for JSP: /WEB-INF/jsp/template/PopupTemplate.jsp> 
    ####<20-Jul-2017 14:47:29 o'clock CEST> <Info> <HTTP> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554849596> <BEA-101341> <ecolabelEar: Class file up-to-date for JSP: /WEB-INF/jsp/template/Template.jsp> 
    ####<20-Jul-2017 14:47:29 o'clock CEST> <Info> <HTTP> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554849612> <BEA-101341> <ecolabelEar: Class file up-to-date for JSP: /WEB-INF/jsp/welcome/defaultMenuBody.jsp> 
    ####<20-Jul-2017 14:47:29 o'clock CEST> <Info> <HTTP> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554849626> <BEA-101341> <ecolabelEar: Class file up-to-date for JSP: /WEB-INF/jsp/welcome/logoutBody.jsp> 
    ####<20-Jul-2017 14:47:29 o'clock CEST> <Info> <HTTP> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554849643> <BEA-101341> <ecolabelEar: Class file up-to-date for JSP: /WEB-INF/jsp/welcome/welcome.jsp> 
    ####<20-Jul-2017 14:47:29 o'clock CEST> <Info> <HTTP> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554849663> <BEA-101341> <ecolabelEar: Class file up-to-date for JSP: /WEB-INF/jsp/welcome/welcomeBody.jsp> 
    ####<20-Jul-2017 14:47:29 o'clock CEST> <Info> <Deployer> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554849839> <BEA-149060> <Module devices of application ecolabelEar successfully transitioned from STATE_NEW to STATE_PREPARED on server myserver.> 
    ####<20-Jul-2017 14:47:29 o'clock CEST> <Info> <WebLogicServer> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554849861> <BEA-000256> <Invoking weblogic.transaction.internal.StartupClass.main(null)> 
    ####<20-Jul-2017 14:47:29 o'clock CEST> <Info> <Deployer> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554849872> <BEA-149059> <Module devices of application ecolabelEar is transitioning from STATE_PREPARED to STATE_ADMIN on server myserver.> 
    ####<20-Jul-2017 14:47:30 o'clock CEST> <Info> <org.hibernate.validator.engine.resolver.DefaultTraversableResolver> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554850444> <BEA-000000> <Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.> 
    ####<20-Jul-2017 14:47:30 o'clock CEST> <Info> <Deployer> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554850447> <BEA-149060> <Module devices of application ecolabelEar successfully transitioned from STATE_PREPARED to STATE_ADMIN on server myserver.> 
    ####<20-Jul-2017 14:47:30 o'clock CEST> <Info> <ServletContext-/devices> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1500554850652> <BEA-000000> <Initializing Spring root WebApplicationContext> 
    ####<20-Jul-2017 14:47:40 o'clock CEST> <Info> <org.hibernate.validator.engine.resolver.DefaultTraversableResolver> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1500554860329> <BEA-000000> <Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.> 
    ####<20-Jul-2017 14:47:40 o'clock CEST> <Info> <ServletContext-/devices> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1500554860918> <BEA-000000> <Initializing log4j from [classpath:com/devices//log4j.properties]> 
    ####<20-Jul-2017 14:47:41 o'clock CEST> <Debug> <SecurityAtn> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554861044> <BEA-000000> <EcasServletAuthenticationFilter@11e13f4 : init weblogic.security.service.internal.ServletAuthenticationFilterServiceImpl$FilterConfigImpl@ec4bb2 for context: ServletContext@13293236[app:ecolabelEar module:devices path:/devices spec-version:3.0]> 
    ####<20-Jul-2017 14:47:41 o'clock CEST> <Debug> <SecurityAtn> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554861496> <BEA-000000> <Registered JASPIC AuthConfigProvider for application.> 
    ####<20-Jul-2017 14:47:41 o'clock CEST> <Info> <ServletContext-/devices> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1500554861542> <BEA-000000> <Initializing Spring FrameworkServlet 'ecolabelWeb'> 
    ####<20-Jul-2017 14:47:42 o'clock CEST> <Info> <org.hibernate.validator.engine.resolver.DefaultTraversableResolver> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1500554862961> <BEA-000000> <Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Info> <Diagnostics> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866282> <BEA-320000> <The Diagnostics subsystem is initializing on Server myserver.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Info> <Log Management> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866314> <BEA-170025> <Initialized Domain Logging. Domain log events will be written to C:\Development\Domains\devices\servers\myserver\logs/mydomain.log.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Notice> <Log Management> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866315> <BEA-170027> <The server has successfully established a connection with the Domain level Diagnostic Service.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Info> <Diagnostics> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866401> <BEA-320077> <Initialized the Diagnostic Accessor Service.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Info> <Log Management> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866436> <BEA-170031> <The default Server Logging bridge has been initialized successfully.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Notice> <WebLogicServer> <D02DI1350859ENV> <myserver> <main> <<WLS Kernel>> <> <> <1500554866456> <BEA-000365> <Server state changed to ADMIN.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Notice> <WebLogicServer> <D02DI1350859ENV> <myserver> <main> <<WLS Kernel>> <> <> <1500554866537> <BEA-000365> <Server state changed to RESUMING.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Info> <Deployer> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866541> <BEA-149059> <Module devices of application ecolabelEar is transitioning from STATE_ADMIN to STATE_ACTIVE on server myserver.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Info> <Deployer> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866542> <BEA-149060> <Module devices of application ecolabelEar successfully transitioned from STATE_ADMIN to STATE_ACTIVE on server myserver.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Info> <Management> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866549> <BEA-141052> <The auto deployment poller has started.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Info> <Server> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866563> <BEA-002610> <Dynamic Listener Service initialized.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Notice> <Server> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866564> <BEA-002613> <Channel "Default" is now listening on 158.166.167.112:7001 for protocols iiop, t3, ldap, snmp, http.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Warning> <Server> <D02DI1350859ENV> <myserver> <DynamicListenThread[Default]> <<WLS Kernel>> <> <> <1500554866564> <BEA-002611> <The hostname "D02DI1350859ENV.net8.pep.ant", maps to multiple IP addresses: 158.166.167.112, 0:0:0:0:0:0:0:1.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Notice> <Server> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866564> <BEA-002613> <Channel "Default[1]" is now listening on 127.0.0.1:7001 for protocols iiop, t3, ldap, snmp, http.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Notice> <Server> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866565> <BEA-002613> <Channel "Default[2]" is now listening on 0:0:0:0:0:0:0:1:7001 for protocols iiop, t3, ldap, snmp, http.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Notice> <WebLogicServer> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866565> <BEA-000331> <Started the WebLogic Server Administration Server "myserver" for domain "mydomain" running in development mode.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Notice> <WebLogicServer> <D02DI1350859ENV> <myserver> <main> <<WLS Kernel>> <> <> <1500554866595> <BEA-000365> <Server state changed to RUNNING.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Notice> <WebLogicServer> <D02DI1350859ENV> <myserver> <main> <<WLS Kernel>> <> <> <1500554866596> <BEA-000360> <The server started in RUNNING mode.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Debug> <SecurityAtn> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866645> <BEA-000000> <Beginning getServletAuthenticationFilters.> 
    ####<20-Jul-2017 14:47:46 o'clock CEST> <Debug> <SecurityAtn> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554866645> <BEA-000000> <PrincipalAuthenticator.getServletAuthenticationFilters will use WLS-specific security service>  
        ####<20-Jul-2017 14:47:48 o'clock CEST> <Info> <EJB> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554868336> <BEA-010009> <EJB deployed EJB with JNDI name ejb.mgmt.MEJB.> 
        ####<20-Jul-2017 14:47:48 o'clock CEST> <Info> <EJB> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554868337> <BEA-014022> <javax.management.j2ee.ManagementHome is bound with JNDI name java:module/Mejb!javax.management.j2ee.ManagementHome.> 
        ####<20-Jul-2017 14:47:48 o'clock CEST> <Info> <EJB> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554868337> <BEA-014022> <javax.management.j2ee.ManagementHome is bound with JNDI name java:global/mejb/Mejb!javax.management.j2ee.ManagementHome.> 
        ####<20-Jul-2017 14:47:48 o'clock CEST> <Info> <EJB> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554868337> <BEA-014022> <javax.management.j2ee.ManagementHome is bound with JNDI name java:app/mejb/Mejb!javax.management.j2ee.ManagementHome.> 
        ####<20-Jul-2017 14:47:48 o'clock CEST> <Info> <EJB> <D02DI1350859ENV> <myserver> <[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1500554868337> <BEA-014021> <The EJB Mejb(Application: mejb, EJBComponent: mejb.jar) has been successfully deployed. The following remote interfaces have been bound into JNDI with the specified JNDI names:> 
        ####<20-Jul-2017 14:48:46 o'clock CEST> <Info> <Health> <D02DI1350859ENV> <myserver> <weblogic.GCMonitor> <<anonymous>> <> <> <1500554926432> <BEA-310002> <50% of the total memory in the server is free.> 

这里是配置文件:

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.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.5.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd 
        ">

    <!-- Use annotations to inject stuff -->
    <context:annotation-config />
    <mvc:annotation-driven />

    <!-- Scan for controllers -->
    <context:component-scan base-package="com.no.en.tenim.ni.cinc.controller.image" />
    <context:component-scan base-package="com.no.en.tenim.ni.cinc.controller" />   
    <context:component-scan base-package="com.no.en.tenim.ni.cinc.audit" />
    <context:component-scan base-package="com.no.en.tenim.ni.cinc.domain.formBeans" />
    <context:component-scan base-package="com.no.en.tenim.ni.cinc.utils" />





    <bean id="resultDecider" class="com.no.en.tenim.ni.cinc.audit.DevicesResultDecider"/>
    <bean id="userLocator"   class="com.no.en.tenim.ni.cinc.audit.BaseContextUserLocator"/>

    <!-- automatically import all controller beans -->
    <import resource="classpath:com/nicinc/Devices/controller/**/*Controller.xml" />

    <!--  The multipartResolver specifies in what way a multi part request should be treated. This enables file upload capabilities. -->
    <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    </bean>

    <bean name="viewBasenames"
        factory-bean="classpathBasenamePatternresolver"
        factory-method="resolve">
        <constructor-arg>
            <list>
                <value>views.**</value>
            </list>
        </constructor-arg>
    </bean>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
        <property name="basenames" ref="viewBasenames" />
    </bean>

    <!-- Maps incoming URLs to classnames -->
    <bean name="controllerHandler" class="springext.web.servlet.mvc.support.ControllerClassNameHandlerMapping">        
        <property name="basePackage" value="com.no.en.tenim.ni.cinc.controller" />        
        <property name="interceptors">
            <list>
                <!-- Checks a specific request parameter if the locale is changed. -->
                <ref bean="localeChangeInterceptor" />
                <ref bean="sessionInterceptor"      />
            </list>
        </property>
    </bean>

    <!-- Action URL mappings to controllers. -->
    <bean id="handlerMapping"
        class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
        <property name="interceptors">
            <list>
                <!-- Checks a specific request parameter if the locale is changed. -->
                <ref bean="localeChangeInterceptor"/>
                <ref bean="sessionInterceptor"/>
            </list>
        </property>
    </bean>

    <bean name="formController" abstract="true">
        <property name="bindOnNewForm" value="true" />
        <property name="sessionForm" value="true" />
        <property name="synchronizeOnSession" value="true" />
        <property name="propertyEditorRegistrar" ref="propertyEditorRegistrar" />
    </bean>

    <!-- Resolves view name to template & body -->
    <bean name="templateViewResolver" class="springext.web.servlet.mvc.support.TemplateViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="templateMap">
            <bean class="springext.web.servlet.mvc.support.TemplateMapFactory">
                <property name="templateDir" value="/WEB-INF/jsp/template/" />
                <property name="templateSuffix" value="Template.jsp" />
                <property name="bodySuffix" value="Body.jsp" />
            </bean>
        </property>
    </bean>

</beans>

和其他

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:jee="http://www.springframework.org/schema/jee"
        xmlns:security="http://www.springframework.org/schema/security"

        xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
        http://www.springframework.org/schema/jee 
        http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-4.0.xsd">


        <!-- As of Spring Security 4.0, CSRF protection is enabled by default with XML configuration -->
        <security:global-method-security secured-annotations="enabled" />

        <security:http auto-config="true">
            <security:csrf/>     
            <security:intercept-url pattern="/**" access="permitAll"    />
        </security:http> 

        <security:authentication-manager/>          


        <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>


        <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
            <property name="customEditors">
                <map>
                    <entry key="java.util.List">
                        <bean class="com.no.en.tenim.ni.cinc.support.beans.ListPropertyEditor" />
                    </entry>
                </map>
            </property>             
        </bean>

        <bean id="sessionInterceptor" class="com.no.en.tenim.ni.cinc.support.context.SessionInterceptor" />

        <!-- The locale resolver determines the locale of a request. -->
        <!-- In this example a cookie is used to store the chosen language. -->
        <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
            <property name="defaultLocale" value="en_GB" />
            <!-- <property name="paramName" value="language" /> -->
        </bean>
        <!-- The locale change interceptor checks a specific request parameter if the locale is changed. -->
        <!-- In this example the request parameter called 'locale' is checked. -->
        <bean id="localeChangeInterceptor"
                class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
        <bean name="classpathBasenamePatternresolver"
                class="com.no.en.tenim.ni.cinc.support.resource.ClassPathBaseNamePatternResolver">
        </bean>

        <bean id="applicationProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
            <property name="locations">
                <list><value>classpath:config/application.properties</value></list>
            </property> 
        </bean>

        <!-- used for internationalized messages, e.g.: validation errors or instant help text. -->
        <bean id="messageSource" class="com.no.en.tenim.ni.cinc.support.context.EnglishMessageSource">
                <property name="dao">
                        <ref bean="databaseMessageSourceDao" />
                </property>
                <property name="defaultLanguage">
                        <value>en</value>
                </property>
                <property name="useCache">
                        <value>false</value>
                </property>             
        </bean>

        <bean name="dateFormat" class="java.text.SimpleDateFormat">
                <constructor-arg value="dd/MM/yyyy" />
        </bean>
        <bean name="customDateEditor" class="org.springframework.beans.propertyeditors.CustomDateEditor">
                <constructor-arg ref="dateFormat" />
                <constructor-arg value="true" />
        </bean>
        <bean name="CustomDictionaryEditor"
                class="com.no.en.tenim.ni.cinc.support.controller.CustomDictionaryEditor">
        </bean>
        <bean id="propertyEditorRegistrar"
                class="com.no.en.tenim.ni.cinc.support.controller.CustomPropertyEditorRegistrar">
                <property name="editors">
                        <map>
                                <entry key="java.util.Date" value-ref="customDateEditor" />
                                <entry key="com.no.en.tenim.ni.cinc.domain.ProductGroup"    value-ref="CustomDictionaryEditor" />
                                <entry key="com.no.en.tenim.ni.cinc.domain.ServiceGroup"    value-ref="CustomDictionaryEditor" />
                                <entry key="com.no.en.tenim.ni.cinc.domain.CompetentBody" value-ref="CustomDictionaryEditor" />
                                <entry key="com.no.en.tenim.ni.cinc.domain.Country"     value-ref="countryReferencePropertyEditor" />
                                <entry key="com.no.en.tenim.ni.cinc.domain.ApplicationSignatory"
                                        value-ref="CustomDictionaryEditor" />
                                <entry key="com.no.en.tenim.ni.cinc.domain.Description"
                                        value-ref="descriptionReferencePropertyEditor" />
                                <entry key="com.no.en.tenim.ni.cinc.domain.Language"
                                        value-ref="languageReferencePropertyEditor" />
                                <entry key="com.no.en.tenim.ni.cinc.domain.ServiceRating"
                                        value-ref="serviceRatingReferencePropertyEditor" />
                                <entry key="com.no.en.tenim.ni.cinc.domain.AccomodationType"
                                        value-ref="accomodationTypeReferencePropertyEditor" />
                        </map>
                </property>
        </bean>

        <bean id="exceptionResolver"
                class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
                <property name="exceptionMappings">
                        <value>
                                com.no.en.tenim.ni.cinc.domain.security.SessionExpiredException=noSessionView
                                com.no.en.tenim.ni.cinc.domain.security.NoSufficientRoleException=noRoleView
                                com.no.en.tenim.ni.cinc.domain.security.NoAccessException=noRoleView
                                com.no.en.tenim.ni.cinc.domain.security.NoUserException=noUserView

                        </value>
                </property>
        </bean>
        <bean id="sessionHelper" class="com.no.en.tenim.ni.cinc.controller.util.SessionHelper">
        </bean>

        <bean id="userMessagesManager" class="com.no.en.tenim.ni.cinc.support.controller.UserMessagesManager" scope="session">
            <aop:scoped-proxy/>
        </bean>
</beans>

最佳答案

你好,试试这个 FTP 连接的配置设置。希望它能解决你的问题。

import java.util.List;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.interceptor.WireTap;
import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.Option;
import org.springframework.integration.ftp.gateway.FtpOutboundGateway;
import org.springframework.integration.ftp.session.DefaultFtpSessionFactory;
import org.springframework.integration.handler.LoggingHandler;
import org.springframework.integration.handler.LoggingHandler.Level;
import org.springframework.messaging.MessageChannel;

@Configuration
public class FtpConfiguration {
    @ServiceActivator(inputChannel = "ftpLS")
    @Bean
    public FtpOutboundGateway getGW() {
        FtpOutboundGateway gateway = new FtpOutboundGateway(sf(), "ls", "payload");
        gateway.setOption(Option.NAME_ONLY);
        gateway.setOutputChannelName("results");
        return gateway;
    }

    @Bean
    public MessageChannel results() {
        DirectChannel channel = new DirectChannel();
        channel.addInterceptor(tap());
        return channel;
    }

    @Bean
    public WireTap tap() {
        return new WireTap("logging");
    }

    @ServiceActivator(inputChannel = "logging")
    @Bean
    public LoggingHandler logger() {
        LoggingHandler logger = new LoggingHandler(Level.INFO);
        logger.setLogExpressionString("'Files:' + payload");
        return logger;
    }

    @Bean
    public DefaultFtpSessionFactory sf() {
        DefaultFtpSessionFactory sf = new DefaultFtpSessionFactory();
        sf.setHost("localhost");
        sf.setPort(2121);
        sf.setUsername("anonymous");
        sf.setPassword("");
        return sf;
    }

    @MessagingGateway(defaultRequestChannel = "ftpLS", defaultReplyChannel = "results")
    public interface Gate {

        List list(String directory);

    }
}

关于java - Spring MVC 3.2.8 : FtpInboundFileSynchronizer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45028610/

有关java - Spring MVC 3.2.8 : FtpInboundFileSynchronizer的更多相关文章

  1. java - 等价于 Java 中的 Ruby Hash - 2

    我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/

  2. java - 从 JRuby 调用 Java 类的问题 - 2

    我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www

  3. java - 我的模型类或其他类中应该有逻辑吗 - 2

    我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我

  4. java - 什么相当于 ruby​​ 的 rack 或 python 的 Java wsgi? - 2

    什么是ruby​​的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht

  5. Observability:从零开始创建 Java 微服务并监控它 (二) - 2

    这篇文章是继上一篇文章“Observability:从零开始创建Java微服务并监控它(一)”的续篇。在上一篇文章中,我们讲述了如何创建一个Javaweb应用,并使用Filebeat来收集应用所生成的日志。在今天的文章中,我来详述如何收集应用的指标,使用APM来监控应用并监督web服务的在线情况。源码可以在地址 https://github.com/liu-xiao-guo/java_observability 进行下载。摄入指标指标被视为可以随时更改的时间点值。当前请求的数量可以改变任何毫秒。你可能有1000个请求的峰值,然后一切都回到一个请求。这也意味着这些指标可能不准确,你还想提取最小/

  6. 【Java 面试合集】HashMap中为什么引入红黑树,而不是AVL树呢 - 2

    HashMap中为什么引入红黑树,而不是AVL树呢1.概述开始学习这个知识点之前我们需要知道,在JDK1.8以及之前,针对HashMap有什么不同。JDK1.7的时候,HashMap的底层实现是数组+链表JDK1.8的时候,HashMap的底层实现是数组+链表+红黑树我们要思考一个问题,为什么要从链表转为红黑树呢。首先先让我们了解下链表有什么不好???2.链表上述的截图其实就是链表的结构,我们来看下链表的增删改查的时间复杂度增:因为链表不是线性结构,所以每次添加的时候,只需要移动一个节点,所以可以理解为复杂度是N(1)删:算法时间复杂度跟增保持一致查:既然是非线性结构,所以查询某一个节点的时候

  7. 【Java入门】使用Java实现文件夹的遍历 - 2

    遍历文件夹我们通常是使用递归进行操作,这种方式比较简单,也比较容易理解。本文为大家介绍另一种不使用递归的方式,由于没有使用递归,只用到了循环和集合,所以效率更高一些!一、使用递归遍历文件夹整体思路1、使用File封装初始目录,2、打印这个目录3、获取这个目录下所有的子文件和子目录的数组。4、遍历这个数组,取出每个File对象4-1、如果File是否是一个文件,打印4-2、否则就是一个目录,递归调用代码实现publicclassSearchFile{publicstaticvoidmain(String[]args){//初始目录Filedir=newFile("d:/Dev");Datebeg

  8. java - 为什么 ruby​​ modulo 与 java/other lang 不同? - 2

    我基本上来自Java背景并且努力理解Ruby中的模运算。(5%3)(-5%3)(5%-3)(-5%-3)Java中的上述操作产生,2个-22个-2但在Ruby中,相同的表达式会产生21个-1-2.Ruby在逻辑上有多擅长这个?模块操作在Ruby中是如何实现的?如果将同一个操作定义为一个web服务,两个服务如何匹配逻辑。 最佳答案 在Java中,模运算的结果与被除数的符号相同。在Ruby中,它与除数的符号相同。remainder()在Ruby中与被除数的符号相同。您可能还想引用modulooperation.

  9. java - Ruby 相当于 Java 的 Collections.unmodifiableList 和 Collections.unmodifiableMap - 2

    Java的Collections.unmodifiableList和Collections.unmodifiableMap在Ruby标准API中是否有等价物? 最佳答案 使用freeze应用程序接口(interface):Preventsfurthermodificationstoobj.ARuntimeErrorwillberaisedifmodificationisattempted.Thereisnowaytounfreezeafrozenobject.SeealsoObject#frozen?.Thismethodretur

  10. java - Java 的 StringReader 的 Ruby 等价物是什么? - 2

    在Java中,可以像这样从一个字符串创建一个IO流:Readerr=newStringReader("mytext");我希望能够在Ruby中做同样的事情,这样我就可以获取一个字符串并将其视为一个IO流。 最佳答案 r=StringIO.new("mytext")和here'sthedocumentation. 关于java-Java的StringReader的Ruby等价物是什么?,我们在StackOverflow上找到一个类似的问题: https://st

随机推荐