小编Kin*_*ere的帖子

实时重新加载在 Spring boot devtools 中不起作用

我在 Spring Boot 应用程序中使用此依赖项:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>
Run Code Online (Sandbox Code Playgroud)

文件说:

默认情况下,更改 /META-INF/maven、/META-INF/resources、/resources、/static、/public 或 /templates 中的资源不会触发重新启动,但会触发实时重新加载

现场重装文件说:

spring-boot-devtools 模块包含一个嵌入式 LiveReload 服务器,可用于在资源更改时触发浏览器刷新。LiveReload 浏览器扩展可从 livereload.com 免费获得,适用于 Chrome、Firefox 和 Safari。

现在,我使用 Maven,我的静态文件夹在 src/main/resources 下,所以我的文件夹结构是:

src/main/resources/static/index.html

这是我的 index.html 文件中的内容:

<!DOCTYPE HTML>
<html>
<head>
    <title>Getting Started: Serving Web Content</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
    <p>HI THERE! Get your greeting <a href="/greeting">here</a></p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我使用 chrome 浏览器,但没有在 chrome 中使用任何实时重新加载浏览器扩展。

我使用这个 Powershell 命令运行应用程序(因为我使用的是 spring boot maven 插件):

mvn …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc spring-boot

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

maven surefire插件是否需要运行单元测试?

使用mvn clean test命令时是否需要maven surefire插件来运行单元测试?

我阅读了文档并知道它说:

Surefire插件在构建生命周期的测试阶段使用,以执行应用程序的单元测试.它以两种不同的文件格式生成报告:

纯文本文件(.txt)XML文件( .xml)默认情况下,这些文件是在$ {basedir}/target/surefire-reports处生成的.

但是,我在没有使用surefire插件的情况下运行测试,它们都通过了.

testing unit-testing maven maven-surefire-plugin

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

为什么 ngOnInit() 在 canActivate() 之前被调用?

我正在使用路由保护,特别是canActivate()方法,但 Angular在调用之前ngOnInit()调用了我的根。AppComponent canActivate

我必须等待一些数据canActivate才能AppComponent在模板中呈现它。

我怎样才能做到这一点?

javascript view typescript canactivate angular

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

gdb显示与代码不同的地址

我试图实现缓冲区溢出攻击,我需要知道我试图溢出的缓冲区的地址.

使用GDB显示的地址与我在代码中执行此操作时的地址不同:

确切的代码:

#include<stdio.h>

int main() {
   char buffer[20];
   printf("%p\n", buffer); // 0xbffff320

   return 0;
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我这样做在gdb中:

p &buffer
Run Code Online (Sandbox Code Playgroud)

我明白了: 0xbffff330

为什么会有差异,它会搞砸我的缓冲区溢出攻击?

我禁用了ALSR和堆栈防护.

谢谢.

编辑1:即使我单步执行gdb并遇到打印行,我也会得到0xbffff320作为地址

编辑2:

环境:在Windows 7上的虚拟框中运行Ubuntu Linux 9映像.

gdb版本:6.8-debian

使用GCC编译,例如:gcc -g -fno-stack-protector filename.c 立即执行:./a.out 地址打印:0xbffff320

然后,在这样的调试器打开:gdb ./a.out 然后输入b main 然后runp &buffer

然后地址是0xbffff330

编辑3:

这是重现行为的gdb日志:

$ gdb ./a.out

b主要

这里的p&buffer/*地址与运行可执行文件时显示的不同*/

步骤通过程序到printf语句/*地址这里和p和缓冲区相同但不同于程序运行时打印的内容*/

c gcc gdb pointers buffer-overflow

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

JUnit @Before和@After在每次测试之前和之后执行

我正在运行测试Spring Boot应用程序的JUnit测试.我有一个@Before方法和@After一个.然后我有一堆@Test方法,它们是实际的测试.

但是,我@Before@After方法分别在每次测试之前和之后执行,而不是在所有测试之前执行一次,并且在所有测试之后执行一次.

难道我也在使用这个注释吗?

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
Run Code Online (Sandbox Code Playgroud)

java junit unit-testing junit4 spring-boot

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

C以十六进制值初始化数组

我想初始化一个16字节的十六进制数组,尤其是0x20(空格字符)值。

正确的方法是什么?

unsigned char a[16] = {0x20};
Run Code Online (Sandbox Code Playgroud)

要么

unsigned char a[16] = {"0x20"};
Run Code Online (Sandbox Code Playgroud)

谢谢

c arrays string hex unsigned

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

Powershell卷曲双引号

我试图在powershell中调用curl命令并传递一些JSON信息.

这是我的命令:

curl -X POST -u username:password -H "Content-Type: application/json" -d "{ "fields": { "project": { "key": "key" }, "summary": "summary", "description": "description - here", "type": { "name": "Task" }}}"
Run Code Online (Sandbox Code Playgroud)

我得到了错误和"无与伦比的大括号",主机无法解决,等等.

然后我尝试用反引号字符为字符串中的双引号添加前缀,但它无法识别-描述json字段中的字符

谢谢

编辑1:

当我在常规批处理文件中编写curl命令时,我使用双引号而没有单引号.此外,在-d字符串中,我转义所有双引号\和命令工作.

在这种情况下,我curl实际上是指向curl.exe.我指定了路径,只是没有在这里列出.我还尝试添加单引号-d,我得到:

curl: option -: is unknown curl: try 'curl --help' or 'curl --manual' for more information
Run Code Online (Sandbox Code Playgroud)

好像它无法识别-JSON中的字符

powershell json curl escaping character-encoding

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

由于冲突,无法删除某些未标记的泊坞窗图像

我无法明确删除一些未标记的docker图像.具体来说,那些带有标签的人<none>.

如果我跑,docker images -a我得到这样的东西:

<none>              <none>              91e54dfb1179        3 months ago        188.3 MB
<none>              <none>              d74508fb6632        3 months ago        188.3 MB
<none>              <none>              c22013c84729        3 months ago        188.3 MB
<none>              <none>              d3a1f33e8a5a        3 months ago        188.1 MB
<none>              <none>              4a5e6db8c069        3 months ago        125.1 MB
<none>              <none>              2c49f83e0b13        3 months ago 
Run Code Online (Sandbox Code Playgroud)

但是,当我输入时,docker rmi -f 2c49f83e0b13我得到:

Error response from daemon: Conflict, 2c49f83e0b13wasn't deleted
Error: failed to remove images: [2c49f83e0b13]
Run Code Online (Sandbox Code Playgroud)

知道可能是什么问题吗?

对于我实际使用的一些图像,这些可能是中间码头图像.但如果是这种情况,那么完成的泊坞窗图像应该已经具有那些先前的图像,并且我没有明确地需要那些中间图像.

docker dockerfile docker-registry

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

Docker 加载命令替换现有的同名镜像

我有一个关于docker load命令的简单问题。

如果本地存储库中存在图像并且运行该docker load命令加载与存储库中的图像同名的图像,旧图像是否会被加载的图像替换?

docker docker-registry

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

Angular HttpClient get方法未调用服务器

我的服务器API已启动并正在运行,但是Angular调用HttpClient.get似乎没有在调用服务器。

这是我正在调用的方法:

private url = 'http://localhost:7002/myproj/api/domain';

callServer (): Observable<string> {
    console.log("in callServer()");
    return this.http.get<string>(this.url);
}
Run Code Online (Sandbox Code Playgroud)

这是基于教程示例代码的

/** GET heroes from the server */
getHeroes (): Observable<Hero[]> {
  return this.http.get<Hero[]>(this.heroesUrl)
}
Run Code Online (Sandbox Code Playgroud)

1)我知道我的API服务器已启动并正在运行。

2)我知道网址正确。

3)服务器甚至没有记录或响应请求(所以我知道请求没有到达服务器。

4)callServer()因为日志消息正在打印到控制台,所以正在调用我的方法。

http angular

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