我有一个基于Spring Web模型 - 视图 - 控制器(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");
}
Run Code Online (Sandbox Code Playgroud)
这是我在控制台中看到的:
before synchronize
after synchronize
Run Code Online (Sandbox Code Playgroud)
在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; …Run Code Online (Sandbox Code Playgroud) 我有一个以字符串格式ddMMyyyy和hh:mm以及TimeZone存储在DB中的日期.我想根据这些信息创建一个Instant,但我不知道该怎么做.
就像是
LocalDateTime dateTime = LocalDateTime.of(2017, Month.JUNE, 1, 13, 39);
Instant instant = dateTime.toInstant(TimeZone.getTimeZone("ECT"));
Run Code Online (Sandbox Code Playgroud) 我想逆向工程我的工作区的注册包,所以我去模型浏览器,点击鼠标右键,我应该看到一个带有选项导入的菜单,菜单选项:
但这就是我所看到的:
这是纸莎草纸的版本
我还试图将包从包浏览器中反向设计的包拖放到类图中,但它没有用完..
我有一个SpringBoot应用程序.使用Spring Initializer,嵌入式Tomcat,Thymeleaf模板引擎和包作为可执行的JAR文件.
我有一个具有2个属性的域对象(initDate,endDate).我想创建2个转换器来处理mySQL DB
@Convert(converter = LocalDateTimeAttributeConverter.class)
private LocalDateTime initDate;
@Convert(converter = ZonedDateTimeAttributeConverter.class)
private ZonedDateTime endDate;
Run Code Online (Sandbox Code Playgroud)
转换器1(可以)
@Converter
public class LocalDateTimeAttributeConverter implements AttributeConverter<LocalDateTime, Timestamp> {
@Override
public Timestamp convertToDatabaseColumn(LocalDateTime localDateTime) {
return (localDateTime == null ? null : Timestamp.valueOf(localDateTime));
}
@Override
public LocalDateTime convertToEntityAttribute(Timestamp sqlTimestamp) {
return (sqlTimestamp == null ? null : sqlTimestamp.toLocalDateTime());
}
}
Run Code Online (Sandbox Code Playgroud)
这是我想要创建的那个
@Converter
public class ZonedDateTimeAttributeConverter implements AttributeConverter<ZonedDateTime, Timestamp> {
@Override
public Timestamp convertToDatabaseColumn(ZonedDateTime zoneDateTime) {
return (zoneDateTime == null ? null : Timestamp.valueOf(zoneDateTime));
} …Run Code Online (Sandbox Code Playgroud) 我有这几个函数,我想知道是否可以将参数传递deviceEvent.hasAlarm()给.map(this::sendSMS)
private void processAlarm (DeviceEvent deviceEvent) {
notificationsWithGuardians.stream()
.filter (notification -> notification.getLevels().contains(deviceEvent.getDeviceMessage().getLevel()))
.map(this::sendSMS)
.map(this::sendEmail);
}
private DeviceAlarmNotification sendSMS (DeviceAlarmNotification notification, DeviceEvent deviceEvent) {
if (deviceEvent.hasAlarm()) {
}
return notification;
}
Run Code Online (Sandbox Code Playgroud) 我在DB中存储了这个时间框架:伦敦(BST)的15:00到16:00的任何一天
当我在此时间帧之间收到事件时,我需要执行一个程序IF.
我现在在巴黎(16:22)运行测试,在伦敦是15:22(因此在存储在数据库中的时间帧之间).
这是我的代码
// create Local Date Time from what I have stored in the DB
LocalDateTime dateTime1 = LocalDateTime.of(2017, Month.JUNE, 15, 15, 00);
LocalDateTime dateTime2 = LocalDateTime.of(2017, Month.JUNE, 15, 16, 00);
Instant now = Instant.now();
System.out.println (now.isAfter (dateTime1.atZone(ZoneId.of("BST", ZoneId.SHORT_IDS)).toInstant()));
System.out.println (now.isBefore(dateTime2.atZone(ZoneId.of("BST", ZoneId.SHORT_IDS)).toInstant()));
Run Code Online (Sandbox Code Playgroud)
理论上现在(在巴黎16:22 /伦敦15:22)是在伦敦(15:00)的dateTime1之后和伦敦的dateTime2(16:00)之前
但我现在不是那个dateTime2之前的那个
是否可以在 th:text 中包含 Html 标签?
例如:
<h2 th:text="'LOCATION INFO Device <strong>' + ${deviceKey} + ' </strong> at ' + ${deviceEventTime} ">
Run Code Online (Sandbox Code Playgroud) 我想将Weblogic库放入本地存储库(安装和配置Maven以进行构建自动化和依赖管理)我在我的工作站中安装了Weblogic版本12.1.2.
我运行这个命令:
mvn -X com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=C:\Oracle\product\11.2.0\client_x86 -Doracle-maven-sync.testingOnly=false
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个错误:
[ERROR] Failed to execute goal com.oracle.maven:oracle-maven-sync:12.2.1-2-0:push (default-cli) on project standalone-pom: Synchronization execution failed:
No resources were processed by the sync plugin -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.oracle.maven:oracle-maven-sync:12.2.1-2-0:push (default-cli)
on project standalone-pom: Synchronization execution failed
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) …Run Code Online (Sandbox Code Playgroud) 我现在正在巴黎运行这段代码,其中12:40,其中ECT = ECT - 欧洲/巴黎
LocalDateTime creationDateTime = LocalDateTime.now(Clock.systemUTC());
ZoneId zone = ZoneId.of(ZoneId.SHORT_IDS.get("ECT"));
System.out.println ("creationDateTime --------------------------> " + creationDateTime);
System.out.println ("creationDateTime.atZone(zone).getHour() ---> " + creationDateTime.atZone(zone).getHour());
System.out.println ("creationDateTime.atZone(zone).getMinute() -> " + creationDateTime.atZone(zone).getMinute());
Run Code Online (Sandbox Code Playgroud)
但我在控制台得到这个
creationDateTime --------------------------> 2017-05-16T10:40:07.882
creationDateTime.atZone(zone).getHour() ---> 10
creationDateTime.atZone(zone).getMinute() -> 40
Run Code Online (Sandbox Code Playgroud)
我不应该得到12:40 ???????
据我所知,构造函数注入强制执行强制依赖,而setter注入允许可选的依赖,但是...
那么这种做法是不可能的???
@Component
public class Car {
@Autowired(required=false)
public Car(Engine engine, Transmission transmission) {
this.engine = engine;
this.transmission = transmission;
}
}
Run Code Online (Sandbox Code Playgroud)