CoreFTP | An FTP library written in C # with no external dependencies | DevOps library
kandi X-RAY | CoreFTP Summary
kandi X-RAY | CoreFTP Summary
CoreFTP is a simple .NET FTP library written entirely in C#, it is targeted at netstandard 1.6, meaning it will run under .NET Core (which is also where it derives its name) and the full .NET framework. This package was inspired due to a lack of packages providing FTP functionality compiled with support for the netstandard API surface. NuGet page is at:
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of CoreFTP
CoreFTP Key Features
CoreFTP Examples and Code Snippets
Community Discussions
Trending Discussions on CoreFTP
QUESTION
EDITS BASED ON SUGGESTION: For brevity, I will remove older code and long part and re-phrase the issue.
I am trying to build the app (Spring boot + Spring Batch) taking the date and config information from command line. Based on suggestions, I can use the application properties? The main aim is to use the same job (task of the job) to download different files form different host/time etc. So, properties file can give the information to use for download and compiled jar should read the info and do its tasks.
Main Entry point.
...ANSWER
Answered 2020-Jun-04 at 12:43You are declaring a bean jobExecutionListener()
in which you create new FileSystemResource(config_file_path);
. The config_file_path
is injected from job parameters @Value("#{jobParameters['ConfigFilePath']}")
which are not available at configuration time but only when a job/step is run. This is called late binding.
So in your case, when Spring tries to create the bean jobExecutionListener()
, it tries to inject config_file_path
but it is null at that time (at this point Spring is only creating beans to configure the application context) and the job is not run yet hence the method beforeJob
is not executed yet. This is the reason you have a NullPointerException
. Adding @JobScope
on the jobExecutionListener()
bean should fix the issue but I do not recommend that. The reason is that you are trying to configure some properties in the wrong way and in the wrong place, so I would fix that design instead of working around the issue by adding an annotation.
Job parameters are used for business parameters and not technical details. In your case, runDate
is a good choice for a job parameter but not ConfigFilePath
. Moreover, since you use Spring, why do you inject the file path then do properties = PropertiesLoaderUtils.loadProperties(resource);
and Integer.parseInt(properties.getProperty("remote.port"));
? Spring will do that for you if tell it to inject properties where needed.
I would remove this config_file_path
job parameter as well as the job listener and inject the properties in the remoteFileInboundTasklet
directly, that is, as close as possible to where these properties are needed.
Edit: Add code example
Can you help to understand where can I declare the tasklet as a bean?
In your step getFilesFromFTPServer
, you are creating the tasklet manually, so dependency injection is not performed. You need to declare the tasklet as a Spring bean for this to work, something like:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install CoreFTP
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page