小编Mat*_*ski的帖子

block()/blockFirst()/blockLast() 是阻塞的,在线程reactor-http-server-epoll-18中不支持

我正在尝试使用 WebTestClient 发布数据但不幸的是抛出了这样的消息:

java.lang.AssertionError: Status expected:<200> but was:<500>

> POST http://localhost:41087/movie
> Accept: [application/json;charset=UTF-8]
> WebTestClient-Request-Id: [1]
> Content-Type: [application/json;charset=UTF-8]
> Content-Length: [101]

{"movieId":1,"title":"Title for movie 1","genre":"Genre for movie 1","address":"Address for movie 1"}

< 500 INTERNAL_SERVER_ERROR Internal Server Error
< Content-Type: [application/json;charset=UTF-8]
< Content-Length: [226]

{"timestamp":"2020-01-03T10:02:18.467+0000","path":"/movie","status":500,"error":"Internal Server Error","message":"block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-server-epoll-18"}


    at org.springframework.test.web.reactive.server.ExchangeResult.assertWithDiagnostics(ExchangeResult.java:200)
    at org.springframework.test.web.reactive.server.StatusAssertions.isEqualTo(StatusAssertions.java:59)
    at org.springframework.test.web.reactive.server.StatusAssertions.isEqualTo(StatusAssertions.java:51)
    at com.geborskimateusz.microservices.core.movie.MovieServiceApplicationTests.postAndVerify(MovieServiceApplicationTests.java:111)
    at com.geborskimateusz.microservices.core.movie.MovieServiceApplicationTests.getMovieNotFound(MovieServiceApplicationTests.java:58)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:515)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115) …
Run Code Online (Sandbox Code Playgroud)

spring reactive-programming spring-boot spring-webflux

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

NoSuchMethodError: org.springframework.plugin.core.PluginRegistry.getPluginOrDefaultFor

一切都很好,即使使用 Swagger,但在新构建项目之后突然无法编译抛出

Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NoSuchMethodError: org.springframework.plugin.core.PluginRegistry.getPluginOrDefaultFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin;
Run Code Online (Sandbox Code Playgroud)

我已经尝试过这个链接的解决方案:https : //github.com/springfox/springfox/issues/2932 但是编译错误仍然存​​在。

我附上 pom.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.geborskimateusz.microservices.composite.movie</groupId>
    <artifactId>movie-composite-service</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <name>movie-composite-service</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <swagger.version>3.0.0-SNAPSHOT</swagger.version>
    </properties>


    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
        <dependency> …
Run Code Online (Sandbox Code Playgroud)

spring swagger spring-boot

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

“路由器”类型上不存在属性“导航”。您指的是“导航”吗?

我不知道为什么,但它突然停止工作......这import是正确的,但它看不到navigate()方法......有什么想法吗?
每个答案都与缺失有关,import但这里有一个正确的答案importnavigate()我的代码的每个部分都停止工作了,哈哈,这只是这里的例子。有任何想法吗?

import { Injectable } from '@angular/core';

import { Actions, Effect, ofType } from '@ngrx/effects';
import * as  AuthActions from './auth.actions'
import * as UserDetailsActions from '../user/user-store/user.actions';
import * as StudentActions from '../../student/student-store/student.actions';

import { map, mergeMap, switchMap, switchMapTo, concatMapTo, withLatestFrom } from 'rxjs/operators';

import { Router } from '@angular/router';

@Injectable()
export class AuthEffects {
    constructor(private actions$: Actions,
                private router: Router) { }

    @Effect()
    authSignin = this.actions$
        .pipe(
            ofType(AuthActions.TRY_SIGNIN), …
Run Code Online (Sandbox Code Playgroud)

javascript routes angular2-routing angular

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

无法找到具有逻辑名称的列:org.hibernate.mapping.Table(user_details) 中的 user_details_id 及其相关的超表和辅助表

我正在尝试创建简单的单向映射。我正在使用 MappedSuperclass 和 @JoinColumn ,可能有问题。看起来实体无法从超类中找到 id 字段。

例外:

Caused by: org.hibernate.MappingException: Unable to find column with logical name: user_details_id in org.hibernate.mapping.Table(user_details) and its related supertables and secondary tables
    at org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:832) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:256) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:101) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processEndOfQueue(InFlightMetadataCollectorImpl.java:1827) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processFkSecondPassesInOrder(InFlightMetadataCollectorImpl.java:1771) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1658) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:287) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:904) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:935) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
Run Code Online (Sandbox Code Playgroud)

超级类:

@Getter
@Setter
@MappedSuperclass
public abstract class BaseEntity {

    @Id
    @GeneratedValue(
            strategy =  GenerationType.IDENTITY
    )
    private Long id;

}
Run Code Online (Sandbox Code Playgroud)

消息实体(连接发送者和接收者的 ID)

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor …
Run Code Online (Sandbox Code Playgroud)

orm hibernate spring-data-jpa spring-boot

4
推荐指数
1
解决办法
9161
查看次数

Java 8过滤器,但返回所有对象

我需要找到大于5个字符的单词,然后将其反转。这样的代码可以正常工作:

public class SpinWords {

    private Function<String, String> reverse = s -> new StringBuilder(s).reverse().toString();


    public String spinWords(String sentence) {

        String whitespace = " ";

        List<String> split = Arrays.asList(sentence.split(whitespace));

        return split.stream().map(s -> {

            if (s.length() > 5) {
                s = reverse.apply(s);
            }

            return s;
        }).collect(Collectors.joining(whitespace));

    }

}
Run Code Online (Sandbox Code Playgroud)

但是由于我现在正在学习Java 8,因此我想将此is语句替换为流,而不使用大括号,而是使用Java 8替代方法。是否可能或此代码有效?

java java-8 java-stream

4
推荐指数
1
解决办法
90
查看次数

NestJS - 增加特定 http 端点的响应超时

我刚刚开始了解 NestJS,我想知道如何操纵特定端点的响应超时?

我可以在服务器级别上执行此操作,例如:

  const server = await app.listen(...);
  server.setTimeout(1800000)
Run Code Online (Sandbox Code Playgroud)

或者在端点上,这看起来很糟糕:

  @Post('/test')
  public async import(...props, @Res() res: Response): Promise<string> {
    res.setTimeout(1800000)
  }
Run Code Online (Sandbox Code Playgroud)

但是我怎样才能在控制器或方法级别上做到这一点呢?我尝试使用拦截器来增加端点的超时,例如:

import { Injectable, NestInterceptor, ExecutionContext, CallHandler, RequestTimeoutException } from '@nestjs/common';
import { Observable, throwError, TimeoutError } from 'rxjs';
import { catchError, take, timeout } from 'rxjs/operators';

@Injectable()
export class TimeoutInterceptor implements NestInterceptor {
  intercept(context: ExecutionContext, next: CallHandler): Observable<any> {

    return next.handle().pipe(
      timeout(1800000),
      catchError(err => {
        if (err instanceof TimeoutError) {
          return throwError(() => new RequestTimeoutException());
        }
        return throwError(() …
Run Code Online (Sandbox Code Playgroud)

javascript node.js express nestjs

4
推荐指数
1
解决办法
2万
查看次数

Kubernetes - 入口:错误:连接 ECONNREFUSED 127.0.0.1:80

我正在尝试在 minikube 上运行 ingress。我在 ubnutu 18.04 上运行。我对 nginx-ingress 感兴趣: https: //kubernetes.github.io/ingress-nginx/deploy/

我有一个简单的测试服务,它在 docker 容器内的端口 3000 上运行。该容器被推送到 docker hub。我在那里有简单的获取请求:

app.get('/api/users/currentuser', (req, res) => {
  res.send('Hi there!');
});
Run Code Online (Sandbox Code Playgroud)

我已经完成的步骤:minikube 启动,然后minikube 插件启用入口,之后我收到来自 minikube 的消息:

  Verifying ingress addon...
  The 'ingress' addon is enabled
Run Code Online (Sandbox Code Playgroud)

但当我尝试验证它是否正在运行时,我认为这工作得不好:Output from kubectl get pods -n kube-system

NAME                                        READY   STATUS      RESTARTS   AGE
coredns-66bff467f8-bhqnk                    1/1     Running     4          2d8h
etcd-minikube                               1/1     Running     4          2d8h
ingress-nginx-admission-create-676jc        0/1     Completed   0          168m
ingress-nginx-admission-patch-bwf7x         0/1     Completed   0          168m
ingress-nginx-controller-7bb4c67d67-x5qzl   1/1     Running     3          168m …
Run Code Online (Sandbox Code Playgroud)

kubernetes skaffold nginx-ingress

2
推荐指数
1
解决办法
7681
查看次数

引起原因:java.sql.SQLSyntaxErrorException:第 1 行“order (id)”附近使用的正确语法的 [...] 版本

此异常与以下内容有关

spring.jpa.hibernate.ddl-auto=update
Run Code Online (Sandbox Code Playgroud)

我还没有尝试保存任何数据

在我看来,映射是正确的,但仍然抛出异常:

org.hibernate.tool.schema.spi.CommandAcceptanceException:通过 JDBC 语句执行 DDL“create table order(id bigint not null auto_increment,order_date date,user_id bigint,primary key(id))engine=MyISAM”时出错

引起原因:java.sql.SQLSyntaxErrorException:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行“order (id)”附近使用的正确语法

我的映射如下所示:

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@MappedSuperclass
public abstract class BaseEntity {

    @Id
    @GeneratedValue(
            strategy = GenerationType.IDENTITY
    )
    private Long id;
}


@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity(name = "Order")
@Table(name = "order")
public class Order extends BaseEntity {

    private LocalDate orderDate;

    @OneToMany(mappedBy = "order", cascade = CascadeType.ALL)
    private List<OrderedTicket> orderedTickets = new ArrayList<>();

    private Long userId; …
Run Code Online (Sandbox Code Playgroud)

mysql hibernate many-to-one spring-data-jpa spring-boot

1
推荐指数
2
解决办法
6244
查看次数