有很多人建议我使用Spring Boot而不是Spring来开发REST Web服务.我想知道两者之间究竟有什么区别?
来自维基百科:
在计算中,红色区域是函数堆栈帧中超出返回地址的固定大小区域,该区域不被该函数保留.被调用函数可以使用红色区域来存储局部变量,而无需修改堆栈指针的额外开销.中断/异常/信号处理程序不会修改此内存区域.System V使用的x86-64 ABI要求一个128字节的红色区域,它直接在返回地址之后开始并包含函数的参数.OpenRISC工具链假设一个128字节的红色区域.
超出%rsp指向的位置的128字节区域被认为是保留的,不应被信号或中断处理程序修改.因此,函数可以将此区域用于函数调用不需要的临时数据.特别是,叶子函数可以将这个区域用于它们的整个堆栈帧,而不是调整序言和尾声中的堆栈指针.这个区域被称为红区.
鉴于这两个引号,堆叠的返回地址上方或堆叠的返回地址下方的红色区域 是?
由于这个红色区域是相对的RSP,它是否向下push移动并且每个区域向上移动pop?
我有一个Spring Boot REST服务,有时会将第三方服务作为请求的一部分.我想在我的所有资源上设置一个超时(让我们说5秒),这样如果任何请求处理(整个链,从传入到响应)花费的时间超过5秒,我的控制器会响应HTTP 503而不是实际响应.如果这只是一个Spring属性,例如设置,那将是非常棒的
spring.mvc.async.request-timeout=5000
Run Code Online (Sandbox Code Playgroud)
但我没有运气.我也尝试过扩展WebMvcConfigurationSupport并覆盖configureAsyncSupport:
@Override
public void configureAsyncSupport(final AsyncSupportConfigurer configurer) {
configurer.setDefaultTimeout(5000);
configurer.registerCallableInterceptors(timeoutInterceptor());
}
@Bean
public TimeoutCallableProcessingInterceptor timeoutInterceptor() {
return new TimeoutCallableProcessingInterceptor();
}
Run Code Online (Sandbox Code Playgroud)
没有运气.
我怀疑我必须手动计算所有第三方呼叫的时间,如果它们花费的时间太长,则抛出超时异常.是对的吗?或者是否有涵盖我所有请求端点的更简单,整体的解决方案?
似乎gcc 4.6.2删除了它认为从函数中未使用的代码.
int main(void) {
goto exit;
handler:
__asm__ __volatile__("jmp 0x0");
exit:
return 0;
}
Run Code Online (Sandbox Code Playgroud)
main() 0x08048404 <+0>: push ebp
0x08048405 <+1>: mov ebp,esp
0x08048407 <+3>: nop # <-- This is all whats left of my jmp.
0x08048408 <+4>: mov eax,0x0
0x0804840d <+9>: pop ebp
0x0804840e <+10>: ret
Run Code Online (Sandbox Code Playgroud)
没有启用优化,只是gcc -m32 -o test test.c(-m32因为我在64位机器上).
我怎么能阻止这种行为?
编辑:最好通过使用编译器选项,而不是通过修改代码.
在我的目标文件夹中,有2个文件夹,lib和conf.所有属性文件都放在conf文件夹中,而jar放在lib foulder中.
在spring boot之前,我们在spring.xml中使用以下配置来使用@value
<context:property-placeholder location="classpath*:*.properties"/>
Run Code Online (Sandbox Code Playgroud)
在java代码中:
@Value("${name}")
private String name;
Run Code Online (Sandbox Code Playgroud)
但在春季启动时,我不知道如何在java代码中做同样的事情.
我试过跟随,但没有工作
@Configuration
@PropertySource(value = "classpath:aaa.properties")
public class AppConfig {
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
Run Code Online (Sandbox Code Playgroud) 我正在编写小型操作系统 - 用于练习.我从bootloader开始.
我想创建一个以16位实模式运行的小命令系统(现在).
我创建了重置驱动器的bootloader,然后在bootloader之后加载扇区.
问题是因为jmp功能后没有任何实际发生.
我不想尝试在0x7E00加载下一个扇区(我不完全确定如何使用es:bx指向地址,这可能是一个问题,我相信它的地址:偏移),就在引导加载程序之后.
这是代码:
;
; SECTOR 0x0
;
;dl is number of harddrive where is bootloader
org 0x7C00
bits 16
;reset hard drive
xor ah,ah
int 0x13
;read sectors
clc
mov bx,0x7E00
mov es,bx
xor bx,bx
mov ah,0x02 ;function
mov al,0x1 ;sectors to read
mov ch,0x0 ;tracks
mov cl,0x1 ;sector
mov dh,0x0 ;head
int 0x13
;if not readed jmp to error
jc error
;jump to 0x7E00 - executed only if loaded
jmp 0x7E00 …Run Code Online (Sandbox Code Playgroud) 我正在编写自己的操作系统.到目前为止,我的代码超过512字节,这太大了,无法容纳在简单的引导扇区中.
据我所知,我现在必须编写一个读取任意代码的引导加载程序,这些代码可能会也可能不会超过一个512字节的扇区.
引导程序需要:
这也是提出涉及操作系统开发的Stack Overflow问题的一个很好的起点.程序员经常很难创建一个Minimal,Complete和Verifiable示例.一个常见的样板/模板将允许其他Stack Overflow用户希望通过有限的大惊小怪来帮助测试代码.
我将如何构建这样一个可重用的引导程序?
我有一个带有弹簧启动的Java Web应用程序
运行测试时我需要排除一些Java配置文件:
测试配置(测试运行时需要包含):
@TestConfiguration
@PropertySource("classpath:otp-test.properties")
public class TestOTPConfig { }
Run Code Online (Sandbox Code Playgroud)
生产配置(测试运行时需要排除):
@Configuration
@PropertySource("classpath:otp.properties")
public class OTPConfig { }
Run Code Online (Sandbox Code Playgroud)
测试类(使用显式配置类):
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestAMCApplicationConfig.class)
public class AuthUserServiceTest { .... }
Run Code Online (Sandbox Code Playgroud)
测试配置:
@TestConfiguration
@Import({ TestDataSourceConfig.class, TestMailConfiguration.class, TestOTPConfig.class })
@TestPropertySource("classpath:amc-test.properties")
public class TestAMCApplicationConfig extends AMCApplicationConfig { }
Run Code Online (Sandbox Code Playgroud)
也有课:
@SpringBootApplication
public class AMCApplication { }
Run Code Online (Sandbox Code Playgroud)
当测试运行时OTPConfig,我需要TestOTPConfig...
我该怎么做?