小编Thi*_*ran的帖子

在访问值之前调用“Optional#isPresent()”

由于我在访问以下代码片段的声纳问题中的值之前收到呼叫“Optional#isPresent()”,请帮助我解决此问题。

List <Department> deptList =new ArrayList();

List<Student> studList=new ArrayList();

Department dept= studList.stream().min(comparator.comparing(Department::getDepartmentNo)).get();
Run Code Online (Sandbox Code Playgroud)

在访问值之前调用“Optional#isPresent()”

java optional java-8 java-stream

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

Ctrl +空格在Spring Tool套件中不起作用

Ctrl + Space在Spring工具套件3.7.3中无法正常工作,但它无法确定出现了什么问题,有人可以指导我去做.

当我尝试这样做时,我收到错误消息说"没有完成可用"

尝试下面的解决方案仍然无法正常配置Eclipse的内容辅助,请转到"首选项> Java>编辑器>内容辅助>高级".确保勾选"其他Java提案" 在此输入图像描述

eclipse eclipse-plugin spring-tool-suite

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

带有 REST 服务的 Spring Reactor

我正在尝试使用 Rest Service 实现 Spring Reactor。控制器

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import reactor.core.publisher.Flux;


@RestController
public class CustomerController {


    @Autowired
    private FluxService fluxService;

    @SuppressWarnings("unchecked")
    @RequestMapping(path = "/handleMessageReactor", method = RequestMethod.POST)
    public Flux<MessageAcknowledgement> handleMessage(@RequestBody Customer message) {
        return fluxService.fluxMethod(message);
    }
}
Run Code Online (Sandbox Code Playgroud)

服务等级

package com.nbcu;

import org.springframework.stereotype.Service;

import reactor.core.publisher.Flux;
@Service
public class FluxService {

    MessageAcknowledgement msg;
    public Flux fluxMethod(Customer cust)
    {

        System.out.println("Name"+cust.getName());
        System.out.println("Address"+cust.getAddress());
        msg=new MessageAcknowledgement("Success");
        return Flux.just(msg);

    }
}
Run Code Online (Sandbox Code Playgroud)

POM文件

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> …
Run Code Online (Sandbox Code Playgroud)

rest spring spring-mvc reactor spring-boot

3
推荐指数
1
解决办法
6572
查看次数

服务注册和发现之间的区别

想了解Zookeeper中的ServiceRegistry和Discovery在微服务方面的区别

microservices apache-zookeeper apache-curator

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

upgrade Spring Boot parent starter from 1.5 into 2.1.1.Release

Getting this below exception as i am trying to upgrade by Spring Boot parent starter from 1.5 into 2.1.1.Release, but not getting any compilation or any Exception in my Project. Is that i am missing anything here.

Exception in thread "main" java.lang.AbstractMethodError: org.springframework.boot.context.config.ConfigFileApplicationListener.supportsSourceType(Ljava/lang/Class;)Z
    at org.springframework.context.event.GenericApplicationListenerAdapter.supportsSourceType(GenericApplicationListenerAdapter.java:79)
    at org.springframework.context.event.AbstractApplicationEventMulticaster.supportsEvent(AbstractApplicationEventMulticaster.java:289)
    at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:221)
    at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:192)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
    at com.nbcuni.compass.schedule.ScheduleServiceApplication.main(ScheduleServiceApplication.java:58)
Run Code Online (Sandbox Code Playgroud)

Same kind of Issue in another service as well.

2018-12-18 12:31:58,999 …
Run Code Online (Sandbox Code Playgroud)

java spring-boot embedded-tomcat-8

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