我是Spring Framework的新手,事实上,我正在学习和使用Spring Boot.最近,在我正在开发的应用程序中,我使Quartz Scheduler工作,现在我想让Spring Integration在那里工作:FTP连接到服务器来写入和读取文件.
我想要的是非常简单(因为我已经能够在以前的Java应用程序中这样做).我有两个Quartz Jobs计划每天在不同的时间点击:其中一个从FTP服务器读取文件,另一个将文件写入FTP服务器.
我将详细介绍我迄今为止开发的内容.
@SpringBootApplication
@ImportResource("classpath:ws-config.xml")
@EnableIntegration
@EnableScheduling
public class MyApp extends SpringBootServletInitializer {
@Autowired
private Configuration configuration;
//...
@Bean
public DefaultFtpsSessionFactory myFtpsSessionFactory(){
DefaultFtpsSessionFactory sess = new DefaultFtpsSessionFactory();
Ftp ftp = configuration.getFtp();
sess.setHost(ftp.getServer());
sess.setPort(ftp.getPort());
sess.setUsername(ftp.getUsername());
sess.setPassword(ftp.getPassword());
return sess;
}
}
Run Code Online (Sandbox Code Playgroud)
我将以下课程命名为FtpGateway,如下所示:
@Component
public class FtpGateway {
@Autowired
private DefaultFtpsSessionFactory sess;
public void sendFile(){
// todo
}
public void readFile(){
// todo
}
}
Run Code Online (Sandbox Code Playgroud)
我正在阅读本文档以学习如何操作.Spring Integration的FTP似乎是事件驱动的,所以我不知道如何在确切的时间触发触发器时执行Jobs中的sendFile()和readFile().
文档告诉我一些使用入站通道适配器(从FTP读取文件?),出站通道适配器(将文件写入FTP?)和出站网关(做什么?):
Spring Integration支持通过FTP/FTPS发送和接收文件,提供三个客户端端点:入站通道适配器,出站通道适配器和出站网关.它还为定义这些客户端组件提供了方便的基于命名空间的配置选项.
所以,我还没有明白如何遵循.
拜托,有人可以给我一个暗示吗? …
我正在使用ant构建我的网络应用程序.我确信这很简单,但我无法弄清楚如何告诉ant在WEB-INF目录中创建一个特定的文件夹并将文件复制到它.
我的蚂蚁战争任务看起来像这样:
<target name="warItUp" depends="compile">
<war destfile="MyApp.war" webxml="${home.dir}\WEB-INF\web.xml">
<classes dir="${classes.dir}"/>
<classes file="${src.dir}/hibernate.cfg.xml"/>
<classes dir="${src.dir}" includes="**/*.hbm.xml"/>
<!-- Include the PDF files -->
<fileset dir="${home.dir}/PDFs">
<include name="**/*.pdf"/>
</fileset>
<!-- Include the JSP files -->
<fileset dir="${home.dir}/JSPs">
<include name="**/*.jsp"/>
</fileset>
<!-- Include the images -->
<fileset dir="${home.dir}/images">
<include name="**/*"/>
</fileset>
</war>
Run Code Online (Sandbox Code Playgroud)
所有文件集元素都可以工作,即它们包含war文件根目录中的pdf,jsp和image文件.
但是如果我想在war文件的WEB-INF目录中创建一个子目录并在其中包含文件,我该如何指定?例如,我想在war文件中包含WEB-INF/TagLibraryDescriptors/MyTagLib.tld,或者我想在war文件中创建一个WEB-INF/JSP文件夹并将所有JSP文件复制到它.
谢谢.
我有一个组件,它作为我所有页面的通用布局存在.该组件的布局如下(使用油漆制作,所以请抱歉:p):
右箭头表示此布局是HorizontalLayout和向下箭头VerticalLayout.
我真的很感兴趣使bodyContent布局可滚动.在这个布局中,我通常会介绍很多UI组件(更多布局,文本字段,表单,网格......),有时由于缺少垂直空间和没有垂直滚动而未显示组件.那么有没有办法让bodyContent可滚动(使用SCSS/CSS或任何其他方式)?
提前致谢.
编辑: 我已经解决了这个感谢@JaneVi:
.v-ui > .v-widget {
overflow: visible;
}
Run Code Online (Sandbox Code Playgroud) 我在Openshift上部署了Web服务。目前,我正在开发一种使用我的Gmail帐户在特定时间发送自动电子邮件的方法。
因此,我已经记录了自己两到三天,得出的结论是我有两个选择:
1)使用JavaMail库。2)使用Gmail API。
对于第一个选项,我使用了以下类:
public class EmailSenderService {
private final Properties properties = new Properties();
private String password = "*******";
private Session session;
private void init() {
//ssl
properties.put("mail.smtp.host", "smtp.gmail.com");
properties.put("mail.smtp.socketFactory.port", "465");
properties.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.port", "465");
session = Session.getDefaultInstance(properties,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("eu***@gmail.com",password);
}
});
}
public void sendEmail(){
init();
//ssl
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("eu***@gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("c***6@gmail.com"));
message.setSubject("Testing Subject");
message.setText("Dear Mail Crawler," +
"\n\n No spam …
Run Code Online (Sandbox Code Playgroud) email jakarta-mail google-api-java-client google-oauth gmail-api
我有一个包含 java.time.LocalDateTime 类型的属性的类。
public class MyClass{
// ...
private LocalDateTime fecha;
// ...
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 Spring Data 存储库。我想要完成的是根据日期查询实体:
@Service
public interface IRepository extends CrudRepository<MyClass, UUID> {
// ...
public void deleteByFecha(LocalDate fecha);
// ...
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为抛出异常:
org.springframework.dao.InvalidDataAccessApiUsageException: 参数值 [2016-10-05] 与预期类型 [java.time.LocalDateTime (n/a)] 不匹配;
所以问题是如何通过fecha但使用 LocalDate查询数据库中的 MyClass ?
编辑 以防万一有人面临同样的问题,我想出了一个解决方案:修改存储库的方法,使其看起来如下:
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
// ...
@Service
public interface IRepository extends CrudRepository<MyClass, UUID> {
@Transactional
@Modifying
@Query("DELETE FROM MyClass mtc WHERE YEAR(mtc.fecha)=?1 AND MONTH(mtc.fecha)=?2 AND DAY(mtc.fecha)=?3")
public …
Run Code Online (Sandbox Code Playgroud) 如何在片段中实现GoogleMap?
我正在尝试开发相同的东西,但getMap()无法执行,因为SupportMapFragment(执行行时(SupportMapFragment)getActivity().getSupportFragmentManager().findFragmentById(R.id.map))返回一个null对象.
我试过扩展MapFragment和SupportMapFragment而不是Fragment,但它们没有用...
我只是不想创建一个新的活动来显示地图:我想显示一个仅仅是Map而不是我的主要活动.我可以实现我的目标吗?
我有一个扩展ActionBarActivity的主要活动,它替换容器内的片段(取决于抽屉上的用户选择,替换并显示X或Y片段).我拥有2个片段,但我无法实现在Fragment中操作GoogleMap对象的目标.
那是我的mapa.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mapaPrincipal"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
Run Code Online (Sandbox Code Playgroud)
这是我的FragmentMapa类:
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.ingartek.bizkaimove.R;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class FragmentMapa extends Fragment {
private GoogleMap mMapa;
public FragmentMapa() {
// TODO Auto-generated constructor stub
}
@Override
public void onAttach (Activity activity) {
super.onAttach(activity);
}
@Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView (LayoutInflater inflater, ViewGroup container, …
Run Code Online (Sandbox Code Playgroud) java android google-maps android-fragments google-maps-android-api-2
我即将开始一个新项目,我们决定使用Play!.我已经配置了我的IDE(Eclipse Luna),但遗憾的是,当我悬停任何函数,类等时,没有任何文档的迹象.
通过互联网看,我想出了Play的github repo(https://github.com/playframework/playframework),他们有一个文档文件夹(https://github.com/playframework/playframework/tree/master/文件).
那么,我如何基于他们的Github文档文件夹生成一个Javadoc?
PS:我正在使用最新的Play版本,即2.3.6,其中播放命令被激活器取代.
我想在我现有的Web应用程序中添加一个连接池,它是使用Spring Boot 1.5.1创建的.
数据源配置在application.properties中进行,如下所示:
spring.datasource.url=jdbc:jtds:sqlserver://localhost:1433;databaseName=MyDatabase;instance=SQLServer2014;
spring.datasource.username=myuser
spring.datasource.password=passwd
spring.datasource.driver-class-name=net.sourceforge.jtds.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
Run Code Online (Sandbox Code Playgroud)
我不需要进行任何进一步的配置,这就足够了.
虽然参数显示在Spring 官方文档中,但在Spring Boot 文档中也没有明确说明.
所以,我一直在那里寻找解决方案(这一个,这也是 ......).
我做了几次试验,但每次运行应用程序时,都会抛出有关HikariCP的例外情况.
添加时spring.datasource.type=com.zaxxer.hikari.HikariDataSource
,抛出以下异常:
2017-02-15 12:12:23.955 WARN 14844 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError
2017-02-15 12:12:23.964 INFO 14844 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display …
Run Code Online (Sandbox Code Playgroud) 我有一个 AWS S3 存储桶,每周都会在其中放置一个新的 ZIP 文件。
我想向使用 Spring Boot 编写的现有 Web 服务添加一项功能:在本地同步存储桶并监视更改。
目前,同步效果良好:每当将新文件添加到存储桶时,都会将其下载到本地。但是,我不知道监听文件更新,这是一种在本地下载新文件时触发的方法。能做到吗?
这是我的一段代码:
# --------
# | AWS S3 |
# --------
s3.credentials-access-key=***
s3.credentials-secret-key=****
s3.bucket = my-bucket
s3.remote-dir = zips
s3.local-dir = D:/s3-bucket/
Run Code Online (Sandbox Code Playgroud)
# --------
# | AWS S3 |
# --------
s3.credentials-access-key=***
s3.credentials-secret-key=****
s3.bucket = my-bucket
s3.remote-dir = zips
s3.local-dir = D:/s3-bucket/
Run Code Online (Sandbox Code Playgroud) amazon-s3 spring-integration spring-boot spring-integration-aws
java ×5
spring ×3
spring-boot ×3
amazon-s3 ×1
android ×1
ant ×1
css ×1
eclipse ×1
email ×1
ftps ×1
gmail-api ×1
google-maps ×1
google-oauth ×1
hibernate ×1
hikaricp ×1
jakarta-mail ×1
java-ee ×1
java-time ×1
javadoc ×1
jtds ×1
spring-data ×1
vaadin ×1
vaadin7 ×1
war ×1