小编Som*_*kar的帖子

@RequestBody MultiValueMap不支持内容类型'application/x-www-form-urlencoded; charset = UTF-8'

基于x-www-form-urlencoded与Spring @Controller的问题的答案

我写了下面的@Controller方法

@RequestMapping(value = "/{email}/authenticate", method = RequestMethod.POST
            , produces = {"application/json", "application/xml"}
            ,  consumes = {"application/x-www-form-urlencoded"}
    )
     public
        @ResponseBody
        Representation authenticate(@PathVariable("email") String anEmailAddress,
                                    @RequestBody MultiValueMap paramMap)
                throws Exception {


            if(paramMap == null || paramMap.get("password") == null) {
                throw new IllegalArgumentException("Password not provided");
            }
    }
Run Code Online (Sandbox Code Playgroud)

请求失败并出现以下错误

{
  "timestamp": 1447911866786,
  "status": 415,
  "error": "Unsupported Media Type",
  "exception": "org.springframework.web.HttpMediaTypeNotSupportedException",
  "message": "Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported",
  "path": "/users/usermail%40gmail.com/authenticate"
}
Run Code Online (Sandbox Code Playgroud)

[PS:泽西岛更加友好,但现在考虑到实际限制,现在无法使用它]

model-view-controller spring spring-mvc

73
推荐指数
7
解决办法
16万
查看次数

带有EnumSet Stream的java.util.stream.Collectors

我试图用代替位掩码来代码

public static Set<Amenities> fromBitFlags(int bitFlag) {
    return ALL_OPTS.stream().filter(a -> (a.ameityId & bitFlag) > 0).collect(Collectors.toSet());
}
Run Code Online (Sandbox Code Playgroud)

我想返回EnumSet而不是简单的集合(不要因为转换而放弃EnumSet的实用性).

需要一些有关如何创建自定义收集器以收集EnumSet的说明.

java enumset java-8 java-stream

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

域驱动设计存储库与Spring Data存储库之间是否存在不匹配?

DDD指定每个聚合的存储库,但是当采用Spring Data JPA时,我们只有在声明每个实体的接口时才能利用这些优势.如何解决阻抗不匹配问题?

我希望尝试封装在聚合存储库中的存储库接口,这是一个好的解决方案还是更好的可用解决方案?

到给定的一个例子:Customer是聚合根和实体等Demographics,Identification,AssetSummary等等,其中每个实体可以从具有自己的资源库接口受益.没有违反DDD的最佳方法是什么?

domain-driven-design ddd-repositories spring-data spring-data-jpa

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

Akka Streams:Mat代表什么来源[out,Mat]

在Akka流中,Mat [Out,Mat]或Sink [In,Mat]中的Mat代表什么.它什么时候才会被使用?

akka reactive-streams akka-stream

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

Scala中的多态函数是"限制性的"吗?

在Scala MEAP v10中的功能编程一书中,作者提到了这一点

多态函数通常受其类型约束,因此它们只有一个实现!

并举例说明

def partial1[A,B,C](a: A, f: (A,B) => C): B => C = (b: B) => f(a, b)
Run Code Online (Sandbox Code Playgroud)

这句话是什么意思?多态函数是否具有限制性?

scala polymorphic-functions

13
推荐指数
2
解决办法
368
查看次数

在Spring中的application.properties中指定相对路径

有没有办法我们可以使用Spring启动应用程序中的application.properties文件中的相对路径查找文件资源,如下所述

spring.datasource.url=jdbc:hsqldb:file:${project.basedir}/db/init
Run Code Online (Sandbox Code Playgroud)

spring spring-boot spring-properties

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

Docker-in-Docker与Gitlab共享运行器,用于构建和将docker镜像推送到注册表

一直试图建立可以构建码头图像的Gitlab CI,并且发现DinD最初仅针对不同的跑步者而启用,而博客建议它很快就会为共享的跑步者启用,

运行DinD需要在运行器中启用特权模式,在注册运行器时将其设置为标志,但无法找到共享运行器的等效机制

docker gitlab-ci gitlab-ci-runner

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

Spring MVC 处理程序拦截器,带有 pathparam 的排除路径模式

我已经编写了一个 HandlerInterceptorAdapter 实现,并希望排除在注册令牌时对用户进行身份验证和刷新用户的路径模式,thje 资源的 URLS 主要将电子邮件地址作为路径参数,以下哪个代码片段是有效的这样做的表格

 @Override
    public void addInterceptors(InterceptorRegistry registry) {
        super.addInterceptors(registry);
        registry.addInterceptor(new AuthorizationInterceptor()).excludePathPatterns("/somepath/*/someresource/*");
    }
Run Code Online (Sandbox Code Playgroud)

或者

@Override
public void addInterceptors(InterceptorRegistry registry) {
    super.addInterceptors(registry);

    registry.addInterceptor(new AuthorizationInterceptor()).excludePathPatterns("/somepath/{email}/someresource/*");
}
Run Code Online (Sandbox Code Playgroud)

编辑:::

使用 PatternMatcher 增强了代码,仍然无法正常工作

 @Override
    public void addInterceptors(InterceptorRegistry registry) {
        super.addInterceptors(registry);

        registry.addInterceptor(new AuthorizationInterceptor())
                .excludePathPatterns(
                        "/somepath",
                        "/somepath/*/authenticate",
                        "somapath/*/someresource/verify"
                ).pathMatcher(new AntPathMatcher());
    }
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc

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

[AWS Glue]:org.apache.thrift.TApplicationException:内部错误处理 createInterpreter

我正在尝试使用 zeppelin-0.8.0 连接到 AWS Glue 开发端点,并且在执行以下单元格时发生错误。并且没有有用的信息来了解可能是什么问题。任何线索表示赞赏

172318_1906434757 is finished, status: ERROR, exception: java.lang.RuntimeException: org.apache.thrift.TApplicationException: Internal error processing createInterpreter, result: %text org.apache.thrift.TApplicationException: Internal error processing createInterpreter
        at org.apache.thrift.TApplicationException.read(TApplicationException.java:111)
        at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:71)
        at org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService$Client.recv_createInterpreter(RemoteInterpreterService.java:209)
        at org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService$Client.createInterpreter(RemoteInterpreterService.java:192)
        at org.apache.zeppelin.interpreter.remote.RemoteInterpreter$2.call(RemoteInterpreter.java:169)
        at org.apache.zeppelin.interpreter.remote.RemoteInterpreter$2.call(RemoteInterpreter.java:165)
        at org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcess.callRemoteFunction(RemoteInterpreterProcess.java:135)
        at org.apache.zeppelin.interpreter.remote.RemoteInterpreter.internal_create(RemoteInterpreter.java:165)
        at org.apache.zeppelin.interpreter.remote.RemoteInterpreter.open(RemoteInterpreter.java:132)
        at org.apache.zeppelin.interpreter.remote.RemoteInterpreter.getFormType(RemoteInterpreter.java:299)
        at org.apache.zeppelin.notebook.Paragraph.jobRun(Paragraph.java:407)
        at org.apache.zeppelin.scheduler.Job.run(Job.java:188)
        at org.apache.zeppelin.scheduler.RemoteScheduler$JobRunner.run(RemoteScheduler.java:307)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Run Code Online (Sandbox Code Playgroud)

更新:所以在下面的答案中看起来 0.8.0 还不能与 Glue 一起使用..我在运行 0.7.x 时遇到了问题,javax.ws.rx 包在使用 Java 8 时有一堆 MethodNotFoundException(也没有帮助更新替代 …

apache-zeppelin aws-glue

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

Apache Flink中定期和间断水印有什么区别?

如果有人给出用例来解释下面给出的每个Watermark API和Apache flink之间的区别,将会很有帮助

  • 定期水印 - AssignerWithPeriodicWatermarks[T]
  • 标点符号 - AssignerWithPunctuatedWatermarks[T]

apache-flink flink-streaming

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