草庐IT

spring-cloud-starter-stream

全部标签

java - Spring,使用 POST 重定向到外部 url

在接下来的Spring3.1操作中,我必须做一些事情并将属性添加到POST请求,然后通过POST将其重定向到外部URL(我不能使用GET)。@RequestMapping(value="/selectCUAA",method=RequestMethod.POST)publicModelAndViewselectCUAA(@RequestParam(value="userID",required=true)Stringcuaa,ModelMapmodel){//query&other...model.addAttribute(PARAM_NAME_USER,cuaa);model.add

java - 在 Java 8 中,如何在不使用 forEach 的情况下从 Stream<int[]> 获取 int 数组

如何转换Stream进入int[]不使用forEach?finalStreamstream=foos.stream().map(foos->insertQuery(contact,create)).map(create::batch).map(Batch::execute);//Batch::executewillreturntheint[] 最佳答案 使用flatMapToIntint[]result=stream.flatMapToInt(Arrays::stream).toArray();

java - Spring @Value 注释返回 null

我正在尝试利用@Value注释并从属性文件自动填充我的字符串变量,但没有成功。值未设置且为null。这是我的配置:SendMessageController.java@RestControllerpublicclassSendMessageController{@Value("${client.keystore.type}")privatestaticStringkeystoreType;@RequestMapping(value="/sendMessage",method=RequestMethod.POST)publicResponseEntitysendMessage(@Vali

java - 仅验证选定的其余端点 : spring boot

我有一个SpringBootWeb应用程序,它公开了几个rest端点。我想知道我们如何才能只为选定的其余端点启用基本身份验证。假设我只想对/employee/{id}请求进行身份验证,而忽略所有其他其余端点。我正在使用以下代码。我的问题是antMatcher是否只验证指定的请求?目前它为所有其余端点启用身份验证:@Configuration@EnableWebSecuritypublicclassWebSecurityConfigextendsWebSecurityConfigurerAdapter{@Overrideprotectedvoidconfigure(HttpSecurit

java - 在 Spring Boot 1.4 中测试安全性

我正在尝试使用SecurityConfig类中定义的自定义安全设置来测试@WebMvcTest:@Configuration@EnableWebSecuritypublicclassSecurityConfigextendsWebSecurityConfigurerAdapter{@Overrideprotectedvoidconfigure(HttpSecurityhttp)throwsException{http.authorizeRequests().antMatchers("/admin*").access("hasRole('ADMIN')").antMatchers("/*

java - 嵌套对象列表的 Spring 配置属性元数据 json

如何为嵌套对象列表配置spring配置元数据json?场景@ConfigurationProperties(prefix="custom-config")publicclassConfigProperties{privatebooleanbooleanProperty;privateListlistProperty=newLinkedList();//gettersandsetters}publicclassNestedObject{privateStringstringProperty;privatebooleanbooleanProperty;//gettersandsetters

java - 如何在 Spring Boot 中设置 ActiveMQ 端口?

我有两个SpringBoot应用程序在一台服务器上运行。两者都使用嵌入式ActiveMQJMS。我想为每个应用程序提供单独的JMS实例。我怎么能为他们每个人设置端口?是否有类似spring.activemq.port的属性?当我运行第二个应用程序时,出现以下预期错误:FailedtostartJMXconnectorCannotbindtoURL[rmi://localhost:1099/jmxrmi]:javax.naming.NameAlreadyBoundException:jmxrmi[Rootexceptionisjava.rmi.AlreadyBoundException:

java - 如何使用 Streams 将二维列表转换为一维列表?

我试过这段代码(list是ArrayList>):list.stream().flatMap(Stream::of).collect(Collectors.toList());但它什么也没做;该列表仍然是一个二维列表。如何将此二维列表转换为一维列表? 最佳答案 您仍然收到列表的原因是因为当您申请Stream::of它正在返回现有流的新流。那是你执行Stream::of的时候这就像有{{{1,2}},{{3,4}},{{5,6}}}然后当你执行flatMap就像这样做:{{{1,2}},{{3,4}},{{5,6}}}->flatMa

java - 如何使用 Memcached 配置 Spring Boot

我是Memcached的新手。我需要使用Memcached配置我的springboot应用程序。我对这个主题进行了很多研究,但找不到相同的文档。默认情况下,Springboot使用ConcurrentHashMap进行缓存,但我该如何配置Memcached。我得到了这个GitHubURL,但我不确定这是否是正确的方式,如果是的话我该如何使用它。https://github.com/sixhours-team/memcached-spring-boothttps://www.javacodegeeks.com/2013/06/simple-spring-memcached-spring-

Java 8 Stream distinct 不起作用

这就是我正在做的:Listscores=Stream.concat(oldEntries.stream(),newEntries.stream()).sorted().distinct().limit(maxSize).collect(Collectors.toList());我期待一个没有任何重复项的排序列表,但有时列表中有重复项。我重写了hashCode和equals方法,我还观察到这些方法每次都返回正确的值。任何人都可以看到我的流有什么问题吗?这是我的equals()和hashCode()它们是由IDEA自动生成的:..privateintuserId;privateintlev