由于我在访问以下代码片段的声纳问题中的值之前收到呼叫“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()”。
我正在尝试使用 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) 想了解Zookeeper中的ServiceRegistry和Discovery在微服务方面的区别
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 ×2
spring-boot ×2
eclipse ×1
java-8 ×1
java-stream ×1
optional ×1
reactor ×1
rest ×1
spring ×1
spring-mvc ×1