小编isA*_*Don的帖子

来自ubuntu绝对路径的Docker COPY

我的dockerfile中有以下行

COPY /root/url.net/volumes/persistent/url/root /usr/share/nginx/html
Run Code Online (Sandbox Code Playgroud)

当我尝试使用docker-compose构建图像时,我得到了

服务'前端'无法构建:lstat /root/url.net/volumes/persistent/url/root:没有这样的文件或目录

我可以从任何地方cd到/root/url.net/volumes/persistent/url/root我的机器没问题.

如何在dockerfile中指定文件夹的绝对路径?

docker dockerfile docker-compose

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

LocalTime在23.59和00:01之间

我想检查一下是否LocalTime是午夜.对于这种使用情况午夜被定义为任何之间23:5900:01.这是2分钟的范围.

private final LocalTime ONE_MINUTE_BEFORE_MIDNIGHT = LocalTime.of(23, 59, 0);
private final LocalTime ONE_MINUTE_AFTER_MIDNIGHT = LocalTime.of(0, 1, 0);
Run Code Online (Sandbox Code Playgroud)

我有一个方法

public boolean isAtMidnight(LocalTime time) {
    return time.isAfter(ONE_MINUTE_BEFORE_MIDNIGHT)
        && time.isBefore(ONE_MINUTE_AFTER_MIDNIGHT);
}
Run Code Online (Sandbox Code Playgroud)

此方法始终返回false.即使是LocalTime.MIDNIGHT.但它应该回归true.

如何查看+-1午夜时间是否分钟?

java time localtime java-time

15
推荐指数
2
解决办法
1627
查看次数

Spring MockMvc验证体是空的

我有一个简单的Spring测试

@Test
public void getAllUsers_AsPublic() throws Exception {
    doGet("/api/users").andExpect(status().isForbidden());
}

public ResultActions doGet(String url) throws Exception {
    return mockMvc.perform(get(url).header(header[0],header[1])).andDo(print());
}
Run Code Online (Sandbox Code Playgroud)

我想验证响应正文是否为空.例如做类似的事情.andExpect(content().isEmpty())

spring spring-test spring-test-mvc

11
推荐指数
2
解决办法
5351
查看次数

Spring Boot&Swagger UI.设置JWT令牌

我有一个像这样的Swagger配置

@EnableSwagger2
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket api() {
        List<SecurityScheme> schemeList = new ArrayList<>();
        schemeList.add(new ApiKey(HttpHeaders.AUTHORIZATION, "JWT", "header"));
        return new Docket(DocumentationType.SWAGGER_2)
                .produces(Collections.singleton("application/json"))
                .consumes(Collections.singleton("application/json"))
                .ignoredParameterTypes(Authentication.class)
                .securitySchemes(schemeList)
                .useDefaultResponseMessages(false)
                .select()
                .apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot")))
                .paths(PathSelectors.any())
                .build();
    }
}
Run Code Online (Sandbox Code Playgroud)

在Swagger UI中,当我单击"授权"按钮时,我在值字段中输入我的JWT标记eyJhbGc..nN84qrBg.现在我希望通过Swagger UI做的任何请求都会在标题中包含JWT.但事实并非如此.没有请求包含Authorization标头.

我错过了什么?

swagger swagger-ui spring-boot swagger-2.0

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

MockMvc为所有请求配置标头

在我的测试中,我设置了MockMvc在对象@Before这样

mockMvc = MockMvcBuilders.webAppContextSetup(context)
                .apply(springSecurity())
                .build();
Run Code Online (Sandbox Code Playgroud)

在我做的每个请求中,我总是需要发送相同的标题.有没有办法配置MockMvc全局或每个测试类使用的头?

spring spring-test mockmvc

6
推荐指数
2
解决办法
3929
查看次数

OpenCV:视频录制太快

我有一个简单的录像机,从我的网络摄像头录制视频。

theVideoWriter.open(filename+countAsString+ext,CV_FOURCC('X','V','I','D'), 30, Size(1920,1080), true);  

    while(recording){
        hasStarted=true;

        webcamRecorder.read(matRecorder); // read a new frame from video
        theVideoWriter.write(matRecorder); //writer the frame into the file
    }
}
hasStarted=false;
cout << "finished recording" << endl;
theVideoWriter.release();
Run Code Online (Sandbox Code Playgroud)

我的问题是,当我播放录制的视频时,视频总是加速并且与实际录制时间不匹配。我知道录制的 FPS 必须与网络摄像头的 FPS 相匹配。webcamRecorder.get(CV_CAP_PROP_FPS)返回 0,因此我使用 Logitech 软件手动录制视频文件,并获得了 30fps 的视频文件。这就是为什么我将 VideoWriter 也设置为 30fps。但录制的视频仍然加速

c++ opencv

5
推荐指数
0
解决办法
1373
查看次数

如何运行HLint?

我才刚开始用 Haskell 编程几周。有人告诉我使用 HLint 来改进我的代码。问题是我不知道如何针对我的 .hs 文件运行 HLint。我阅读了文档,并且能够使用cabal install hlint. 下一步是使用 HLint 运行 HLint hlint myfile.hs。我不知道在哪里输入这一行。cmd 和 ghci 都不会让我运行命令。我在这里缺少什么?

我正在使用窗户。

编辑:

我刚刚删除了 Haskell 并在我的系统上重新安装了它。我认为问题出在我的 Haskell 安装上。这就是我尝试再次安装 HLint 时得到的结果: 在此处输入图片说明

该文件确实存在C:\Users\PCPCPCCP\AppData\Roaming\cabal\setup-exe-cache

编辑2:

好像 hlint 没有正确安装。即使在重新安装了 haskell 平台之后,我也无法在我的系统上安装 hlint。但是,我确实在我的虚拟机上工作过...

haskell hlint

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

Set-Cookie无法在浏览器中运行,但可与Postman配合使用

前端位于localhost:4200,后端位于localhost:8080

我在后端和前端实现了CORS配置,所有其他API请求都可以工作.但是,Set-Cookie标志不会在我的浏览器中创建cookie.

我甚至在chrome中禁用了CORS.

当我使用Postman发出POST请求时,我正确地在Cookie选项卡中看到Cookie.我没有在网络浏览器中看到cookie.

选项请求

Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Access-Control-Request-Method: POST
Access-Control-Request-Headers: content-type,credentials
Run Code Online (Sandbox Code Playgroud)

选项回应

X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Access-Control-Allow-Origin: http://localhost:4200
access-control-allow-credentials: true
access-control-allow-methods: POST, GET, OPTIONS, DELETE
access-control-max-age: 3600
access-control-allow-headers: Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers, credentials
Allow: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH
Content-Length: 0
Date: Fri, 30 …
Run Code Online (Sandbox Code Playgroud)

cookies angular

5
推荐指数
2
解决办法
2504
查看次数

Repository 中的 deleteAll() 随机导致 ConstraintViolationException

我有对 API 执行 CRUD 操作的测试。在每次测试之前,都会重新创建 API 中的测试数据。意思是删除数据库中的所有数据并重新插入测试数据。

public void initDatabase() {
    answerTranslationRepository.deleteAll();
    answerRepository.deleteAll();
    userRepository.deleteAll();
    //....

    Answer answer = new Answer();
    AnswerTranslation answerTranslation = new AnswerTranslation("test", answer);
    //....

    answerTranslationRepository.save(answerTranslation);
    answerRepository.save(answer);  
}
Run Code Online (Sandbox Code Playgroud)

运行所有测试在大多数情况下都有效,但有时调用answerRepository.deleteAll();会失败,并显示:

2018-04-01 09:09:49.069 ERROR 14260 --- [           main] o.h.i.ExceptionMapperStandardImpl        : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]

org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [fkco3o4hxryohduthxj2vgnuhxs]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement

    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:259)
    //..... 
    at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:536)
    ... 54 more
Caused …
Run Code Online (Sandbox Code Playgroud)

java spring hibernate spring-data

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

Travis手动确认下一阶段

我有一个舞台testproduction。我想手动确认部署到生产环境。有办法实现吗?

travis-ci

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