小编Jon*_*lff的帖子

GraphQL和Spring Boot 2.0.3

我想为将来的项目测试GraphQL。该项目将使用Spring Boot,Spring Security和GraphQL。因此,我使用Spring Initializr中的构建在IntelliJ中创建了一个新的Spring Boot App。当然,Spring Boot版本是最新的(2.0.3.RELEASE)现在,我添加了GraphQL和GraphiQL的依赖项。

<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId>graphql-spring-boot-starter</artifactId>
    <version>4.3.0</version>
</dependency>
<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId>graphql-java-tools</artifactId>
    <version>5.2.0</version>
</dependency>
<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId>graphiql-spring-boot-starter</artifactId>
    <version>4.3.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

为了对此进行测试,我运行了该应用程序,但没有/graphql端点。在这种情况下,我application.properties毫无问题地对其进行了配置:

# GraphQL
graphql.servlet.mapping=/graphql
graphql.servlet.enabled=true
graphql.servlet.corsEnabled=true
# GraphiQL
graphiql.mapping=/graphiql
graphiql.endpoint=/graphql
graphiql.enabled=true
graphiql.cdn.enabled=true
graphiql.cdn.version=0.11.11
Run Code Online (Sandbox Code Playgroud)

再次测试之后,端点就在那里了,所以现在我可以编写模式,解析器等了。这是我实现的:

架构:

schema {
    query: Query
    mutation: Mutation
}

type Greeting {
    id: ID!
    message: String!
}

type Query {
    greetingsAll: [Greeting]
}

type Mutation {
    greeting(message: String!): Greeting
}
Run Code Online (Sandbox Code Playgroud)

模型:

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Builder
@ToString
@Entity
public class Greeting …
Run Code Online (Sandbox Code Playgroud)

java spring-boot graphql graphql-java graphiql

6
推荐指数
1
解决办法
4022
查看次数

FTPClient SocketTimeoutException 读取超时

我有一个给定的 FTP 服务器。我可以通过 WinSCP 和其他程序连接到服务器。我已经通过 Java 连接到服务器,但过了一段时间我无法连接。根据 WinSCP,我可以一直连接。现在的问题是服务器是问题的原因还是程序的原因。

有我的代码:

private FTPClient ftpClient = null;

public FtpServerConnector() throws Exception {
    ftpClient = new FTPClient();
    ftpClient.connect(url);
    ftpClient.login(username, password);
}

public List<FTPFile> getDirectory(String directoryPath) throws Exception {
    FTPFile[] files = ftpClient.listFiles(directoryPath);
    List<FTPFile> result = new ArrayList<FTPFile>();
    for (FTPFile ftpFile : files) {
        if (ftpFile.getTimestamp().getTime().getTime() >= Long.parseLong("1451606400000")) {
            result.add(ftpFile);
        }
    }
    return result;
}

public static void main(String[] args) {
    try {
        FtpServerConnector ftpServerConnector = new FtpServerConnector();
        List<FTPFile> folders = ftpServerConnector.getDirectory("/");
        for (FTPFile ftpFile …
Run Code Online (Sandbox Code Playgroud)

ftp socket-timeout-exception

5
推荐指数
1
解决办法
4722
查看次数