我正在使用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定义中的使用位置和方式.
我希望能够做到这样的事情:
@POST
public void postFoo(@Valid @RequestBody FooDTO fooDto) {...}
Run Code Online (Sandbox Code Playgroud)
public class FooDTO {
@NotNull
@Size(min = 1, max = …
Run Code Online (Sandbox Code Playgroud) 我有一个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层进行测试.
我需要更新我继承angular-cli.json
的@angular/cli
项目的配置设置,但Angular-CLI Wiki没有关于该JSON文件内容的任何信息,也没有可用的选项.
如何获取angular-cli.json
配置设置中可用的所有属性的列表?
最接近的似乎是这个ng get
文档,但这假设我知道所有的属性.
我有一个Angular/JHipster应用程序,可以进行HTTP调用.我想在我的Observable
订阅中进行错误处理.
但是,当第一次调用错误处理程序时,该err
对象不是响应,它是原始的{}
Object
.所有后续错误处理程序调用都有效Response
.
为什么会发生这种情况,我该如何解决?
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) 我正在尝试用反应异步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)
然后,Observable
我WebSocketHandler
使用RxReactiveStream.toPublisher
转换器连接到我:
@Bean
WebSocketHandler dbWebSocketHandler() {
return …
Run Code Online (Sandbox Code Playgroud) Flux.create
和之间有什么区别Flux.generate
?我正在寻找 - 理想情况下使用示例用例 - 来了解何时应该使用其中一个.
我正在使用git-sourced,maven管理的Java项目进行合作,该项目使用多个IDE的用户具有不同的代码样式首选项(注释1).
是否有工具或IDE配置允许使用样式1查看和编辑代码,但是使用样式2提交给SCM ?
我的研究指出我'不',但结合git hooks和Checkstyle/jrefactory的解决方案可能是可能的.
因此,如果上面的"否",是否有一个工具/流程将执行下面的TBD流程操作?
User1的结帐流程将是:
git pull
User1的提交工作流程将是:
git push
注1:多个IDE = Eclipse,IntelliJ,Netbeans.
注2:我的问题与这个问题的不同之处在于我想关注与IDE相关的解决方案,因为迫使少数标准不同的用户可能是一种更有效的解决方案.
注3:承认不应该出于最佳实践原因这样做.但是,如果您认为我们的IDE和SCM需要更多的灵活性,那么这个问题就是为了探索这些解决方案.
我想创建一个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) 在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
,jobExecutionContext
和stepExecutionContext
?
Spring Batch版本1.x与2.x与3.x之间的差异也可能存在差异 - 该领域的文档非常缺乏.
我有一个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)
这个标准的父子关系parent-foo
继承自root
,child-n
继承自parent-foo
.
root -> parent-foo -> child-n
Run Code Online (Sandbox Code Playgroud)
这一切都很好,并且适用于这个简单的案例.
使用parent-foo
作品为foo
基础的传统使用的情况下,也考验,我们要迁移过以后的使用情况:bar
.
/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)
root -> parent-bar -> child-n
Run Code Online (Sandbox Code Playgroud)
我是否可以实现以下反应堆构建,而无需每次都修改child-n
POM 的解决方法?或者,类似的东西?或者,Maven是否只是这个用例的错误工具?
[INFO] ------------------------------------------------------------
[INFO] Reactor …
Run Code Online (Sandbox Code Playgroud) spring ×3
angular ×2
git ×2
java ×2
angular-cli ×1
coding-style ×1
eclipse ×1
git-config ×1
inheritance ×1
jhipster ×1
maven ×1
postgresql ×1
promise ×1
rx-java ×1
spring-batch ×1
spring-el ×1
swagger ×1
testing ×1
typescript ×1
validation ×1
websocket ×1