小编JJ *_*kar的帖子

在DTO上配置Swagger javax验证约束

我正在使用Swagger(1.5.8).我希望我的swagger.json定义能够在我的DTO上检测javax.validation JSR-303注释,以便我可以记录我的API的验证约束.

我希望@Min注释(如本例)会显示最小值(44),但事实并非如此.

@POST
@ApiOperation(value = "post", httpMethod = "POST")
public Response post(
        @QueryParam("id") @NotNull @Min(44) Integer id) {...}
Run Code Online (Sandbox Code Playgroud)

结果swagger.json是:

"/foo": {
  "post": {
    "operationId": "post",
    ...
    "parameters": [
      {
        "in": "body",
        "name": "id",
        "description": "id",
        "required": false,
        "schema": {
          "type": "integer",
          "format": "int32"
        }
      }
Run Code Online (Sandbox Code Playgroud)

Swagger 关闭了此功能的pull请求,但我不清楚它在Swagger定义中的使用位置和方式.

我希望能够做到这样的事情:

FooController的

@POST
public void postFoo(@Valid @RequestBody FooDTO fooDto) {...}
Run Code Online (Sandbox Code Playgroud)

FooDTO

public class FooDTO {
    @NotNull
    @Size(min = 1, max = …
Run Code Online (Sandbox Code Playgroud)

java validation swagger

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

Spring Security HttpSecurity配置测试

我有一个Spring Boot + Spring Security应用程序,它有几个antMatchers路径; 一些fullyAuthenticated(),一些permitAll().

如何编写一个测试验证SecurityConfiguration我的端点/api/**(以及最终其他)是否正确安全?

public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    protected void configure(HttpSecurity http) throws Exception {
        http
            //...
            .antMatchers("/api/**").fullyAuthenticated()
    }

}
Run Code Online (Sandbox Code Playgroud)

使用spring-boot-1.5.2.RELEASE,spring-security-core-4.2.2-release.

澄清1:我希望尽可能直接测试SecurityConfiguration,而不是通过其中一个/api/**端点进行传递测试,这些端点可能有自己的@PreAuthorize安全性.

澄清2:我想要类似于这个WebSecurityConfigurerAdapterTests的东西.

澄清3:@Autowire理想情况下HttpSecurity,我想在Spring Security层进行测试.

testing spring spring-security

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

什么是angular-cli.json选项?

我需要更新我继承angular-cli.json@angular/cli项目的配置设置,但Angular-CLI Wiki没有关于该JSON文件内容的任何信息,也没有可用的选项.

如何获取angular-cli.json配置设置中可用的所有属性的列表?

最接近的似乎是这个ng get文档,但这假设我知道所有的属性.

angular-cli angular

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

Angular HTTP Error Empty Untyped Response

我有一个Angular/JHipster应用程序,可以进行HTTP调用.我想在我的Observable订阅中进行错误处理.

但是,当第一次调用错误处理程序时,该err对象不是响应,它是原始的{} Object.所有后续错误处理程序调用都有效Response.

为什么会发生这种情况,我该如何解决?

MyComponent.ts:

handleClickPost() {
    this.myService.doPost(this.body)
    .subscribe(
        (res: Response) => {
            this.responseOk = true;
        },
        (err: Response) => {
            // This is a HACK!
            // For some reason, the first time this error handler is invoked (after page load),
            // the response body is empty here and serializes to "{}".
            if (JSON.stringify(err) === '{}') {
                // first request always reaches here... WHY?
                this.handleClickPost(); // NB: workaround
                // err.json(); // results …
Run Code Online (Sandbox Code Playgroud)

error-handling promise typescript jhipster angular

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

Spring Webflux Async PostgreSQL Publisher在第一个结果后停止

我正在尝试用反应异步postgres-async-driver替换PostgreSQL数据库轮询并将新插入的行流式传输到Spring 5 Webflux Reactive websocket客户端,例如Josh Long 在这里演示并基于SébastienDeleuze的 spring-reactive-playground的很棒的示例.

Publisher获得第一个row,但后来没有返回后续行.是问题,我Observable,我Publisher,或者我如何使用Postgres的,异步驱动程序Db

public Observable<WebSocketMessage> getObservableWSM(WebSocketSession session){
    return
        // com.github.pgasync.Db
        db.queryRows(sql)
        // ~RowMapper method
        .map(row -> mapRowToDto(row))
        // serialize dto to String for websocket
        .map(dto -> { return objectMapper.writeValueAsString(dto); })
        // finally, write to websocket session 
        .map(str -> { return session.textMessage((String) str);
        });
}
Run Code Online (Sandbox Code Playgroud)

然后,ObservableWebSocketHandler使用RxReactiveStream.toPublisher转换器连接到我:

@Bean
WebSocketHandler dbWebSocketHandler() {
    return …
Run Code Online (Sandbox Code Playgroud)

postgresql spring websocket rx-java spring-webflux

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

Flux.create和Flux.generate之间的差异

Flux.create和之间有什么区别Flux.generate?我正在寻找 - 理想情况下使用示例用例 - 来了解何时应该使用其中一个.

project-reactor

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

如何适应多种编码风格?(git与IDE)

我正在使用git-sourced,maven管理的Java项目进行合作,该项目使用多个IDE的用户具有不同的代码样式首选项(注释1).

是否有工具或IDE配置允许使用样式1查看和编辑代码,但是使用样式2提交给SCM ?

我的研究指出我'不',但结合git hooksCheckstyle/jrefactory的解决方案可能是可能的.

因此,如果上面的"否",是否有一个工具/流程将执行下面的TBD流程操作?

User1的结帐流程将是:

  1. git pull
  2. TBD进程将代码格式化为User1 style-1
  3. User1使用样式1设置在其首选IDE中工作

User1的提交工作流程将是:

  1. User1准备提交/推送代码
  2. TBD过程将代码格式化为标准格式样式标准
  3. git push

注1:多个IDE = Eclipse,IntelliJ,Netbeans.

注2:我的问题与这个问题的不同之处在于我想关注与IDE相关的解决方案,因为迫使少数标准不同的用户可能是一种更有效的解决方案.

注3:承认不应该出于最佳实践原因这样做.但是,如果您认为我们的IDE和SCM需要更多的灵活性,那么这个问题就是为了探索这些解决方案.

java eclipse git coding-style intellij-idea

9
推荐指数
2
解决办法
2159
查看次数

通过命令行使用引号和管道进行配置别名

我想创建一个sh配置所有git别名的脚本.一些别名有|pipe(")和doublequotes().我想在我的~/.gitconfig文件中看到的输出是:

[alias]
    assume = update-index --assume-unchanged
    unassume = update-index --no-assume-unchanged
    assumed = "!git ls-files -v | grep ^h | cut -c 3-"
Run Code Online (Sandbox Code Playgroud)

但是,运行以下三个命令会产生错误的assumed条目:

# setup git aliases per: http://blog.apiaxle.com/post/handy-git-tips-to-stop-you-getting-fired/
git config --global alias.assume "update-index --assume-unchanged"
git config --global alias.unassume "update-index --no-assume-unchanged"
git config --global alias.assumed '"!git ls-files -v | grep ^h | cut -c 3-"'
Run Code Online (Sandbox Code Playgroud)

第三个别名(assumed)有不需要的反斜杠:

assumed = \"!git ls-files -v | grep ^h | cut -c 3-\" …
Run Code Online (Sandbox Code Playgroud)

git git-config

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

什么是Spring Batch"默认"上下文变量?

Spring Batch的步范围文档中,有三个原因不明的弹簧一批关系网图:jobParameters,jobExecutionContext,和stepExecutionContext.

Springsource示例代码,合并:

<bean id="flatFileItemReader" scope="step"
  class="org.springframework.batch.item.file.FlatFileItemReader">
    <property name="var1" value="#{jobParameters['input.file.name']}" />
    <property name="var2" value="#{jobExecutionContext['input.file.name']}" />
    <property name="var3" value="#{stepExecutionContext['input.file.name']}" />
</bean>
Run Code Online (Sandbox Code Playgroud)

什么是默认的参数范围内使用jobParameters,jobExecutionContextstepExecutionContext

Spring Batch版本1.x与2.x与3.x之间的差异也可能存在差异 - 该领域的文档非常缺乏.

spring spring-batch spring-el

8
推荐指数
2
解决办法
4484
查看次数

Maven:多个父POM?

我有一个foo具有以下POM结构的多模块项目:

Foo POM结构

/pom.xml             (root/'grandparent' POM)
/parent-foo/pom.xml  (a parent with 'foo' dependencies & configurations) 
/child-1/pom.xml     
...
/child-n/pom.xml   
Run Code Online (Sandbox Code Playgroud)

Foo POM继承

这个标准的父子关系parent-foo继承自root,child-n继承自parent-foo.

root -> parent-foo -> child-n
Run Code Online (Sandbox Code Playgroud)

这一切都很好,并且适用于这个简单的案例.

(未来)用例

使用parent-foo作品为foo基础的传统使用的情况下,也考验,我们要迁移过以后的使用情况:bar.

酒吧

Bar POM结构

/pom.xml             (root POM)
/parent-bar/pom.xml  (a parent with 'bar' dependencies & configurations) 
/child-1/pom.xml     
...
/child-n/pom.xml 
Run Code Online (Sandbox Code Playgroud)

Bar POM继承

root -> parent-bar -> child-n
Run Code Online (Sandbox Code Playgroud)

我是否可以实现以下反应堆构建,无需每次都修改child-nPOM 的解决方法?或者,类似的东西?或者,Maven是否只是这个用例的错误工具?

[INFO] ------------------------------------------------------------
[INFO] Reactor …
Run Code Online (Sandbox Code Playgroud)

inheritance maven

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