我知道当一个Lambda函数失败时(例如当有一个超时)时,它会再次尝试再运行该函数3次.有什么方法可以避免这种行为吗?我一直在阅读文档,但没有找到任何关于这个.
谢谢!
我正在尝试使用Docker 的图像elk-docker(https://elk-docker.readthedocs.io/),使用Docker Compose..yml文件是这样的:
elk:
image: sebp/elk
ports:
- "5601:5601"
- "9200:9200"
- "5044:5044"
Run Code Online (Sandbox Code Playgroud)
当我运行命令:sudo docker-compose up时,控制台显示:
* Starting Elasticsearch Server
sysctl: setting key "vm.max_map_count": Read-only file system
...fail!
waiting for Elasticsearch to be up (1/30)
waiting for Elasticsearch to be up (2/30)
waiting for Elasticsearch to be up (3/30)
waiting for Elasticsearch to be up (4/30)
waiting for Elasticsearch to be up (5/30)
waiting for Elasticsearch to be up (6/30)
waiting for Elasticsearch to be up …Run Code Online (Sandbox Code Playgroud) 我正在学习Flyway迁移工具,我没有明确校验和的概念.有人可以解释一下是什么吗?它是如何计算的,或者如何改变?
我理解修复命令重新计算校验和,我不明白它是如何不同的.
谢谢!
我有一个从 ActivatedRoute 的 params 属性获取值的组件。
组件看起来像:
......
constructor(public userRegistration: UserRegistrationService, public userLogin: UserLoginService,
public router: Router, public route: ActivatedRoute) {
}
ngOnInit() {
this.verificationCode = new FormControl('', [Validators.required]);
this.confirmationCodeForm = new FormGroup({verificationCode: this.verificationCode});
//******************************
this.sub = this.route.params.subscribe(params => {
this.email = params['userId'];
});
//******************************
this.errorMessage = null;
}
......
Run Code Online (Sandbox Code Playgroud)
该测试提供了一个 ActivatedRoute 作为模拟该类的“useValue”。测试看起来像:
describe('ConfirmRegistrationComponent', () => {
let component: ConfirmRegistrationComponent;
let fixture: ComponentFixture<ConfirmRegistrationComponent>;
let userRegistrationService: UserRegistrationService;
let userLoginService: UserLoginService;
let router: Router;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, FormsModule, RouterTestingModule, HttpClientModule], …Run Code Online (Sandbox Code Playgroud) 我在尝试运行测试时遇到以下错误:
org.springframework.web.util.NestedServletException:请求处理失败; 嵌套异常是java.lang.IllegalStateException:Validator [userCreateFormValidator bean]的目标无效:com.ar.empresa.forms.UserCreateForm@15c3585
引起:java.lang.IllegalStateException:验证器[userCreateFormValidator bean]的目标无效:com.ar.empresa.forms.UserCreateForm@15c3585 org.springframework.valid.VeridFatate.alsert位于sun.reflect.NativeMethodAccessorImpl的sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)的com.ar.empresa.controllers.UserController.initBinder(UserController.java:36)中的.validation.DataBinder.addValidators(DataBinder.java:578) .invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)
代码是:
控制器:
@Controller
public class UserController {
private UserService userService;
private UserCreateFormValidator userCreateFormValidator;
@Autowired
public UserController(UserService userService, UserCreateFormValidator userCreateFormValidator) {
this.userService = userService;
this.userCreateFormValidator = userCreateFormValidator;
}
@InitBinder("form")
public void initBinder(WebDataBinder binder) {
binder.addValidators(userCreateFormValidator);
}
@PreAuthorize("hasAuthority('ADMIN')")
@RequestMapping(value = "/user/create", method = RequestMethod.GET)
public ModelAndView getUserCreatePage() {
return new ModelAndView("user_create", "form", new UserCreateForm());
}
@PreAuthorize("hasAuthority('ADMIN')")
@RequestMapping(value = "/user/create", method = RequestMethod.POST)
public String handleUserCreateForm(@Valid @ModelAttribute("form") UserCreateForm form, BindingResult bindingResult) …Run Code Online (Sandbox Code Playgroud) 我正在使用 Cucumber 编写验收测试,并且我想使用 H2 数据库进行测试。
application-test.properties 如下所示:
server.port:8090
spring.jpa.database=H2
spring.database.driverClassName=org.h2.Driver
spring.datasource.url:jdbc:h2:mem:database_user;DB_CLOSE_ON_EXIT=FALSE
flyway.locations=classpath:resources/db/migration
flyway.enabled=true
spring.datasource.username:SA
spring.datasource.password:
spring.h2.console.enabled=true
spring.jpa.show-sql=true
security.basic.enabled:false
spring.application.name=userService
Run Code Online (Sandbox Code Playgroud)
在目录 resources/db/migration 中,我有一个包含以下脚本的 sql 文件:
create table user_image(
id int unsigned not null AUTO_INCREMENT,
url varchar(1000) not null,
s3_key varchar(200) not null,
PRIMARY KEY (id)
);
create table user (
id int unsigned not null AUTO_INCREMENT,
email varchar(50) not null,
password varchar(100) not null,
first_name varchar(50) not null,
last_name varchar(50) not null,
description varchar(50),
phone_number varchar(50),
user_image_id int unsigned,
need_refresh_pass boolean …Run Code Online (Sandbox Code Playgroud) 我正在尝试将 Json 文件从 Swagger 导入到 insomnia。为此,我使用 NPM 中的这个项目(我不熟悉 NPM):
https://www.npmjs.com/package/insomnia-importers
我安装了 npm v6.5.0 和 Node v11.9.0。
我运行了这个命令:`insomnia-import /path/to/swagger-export.json
失眠-export.json:
(node:38053) UnhandledPromiseRejectionWarning: TypeError: Cannot
convert undefined or null to object
at Function.keys (<anonymous>)
at object (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:300:14)
at generateParameterExample (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:332:12)
at Object.keys.forEach.propertyName (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:301:33)
at Array.forEach (<anonymous>)
at object (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:300:31)
at generateParameterExample (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:332:12)
at prepareBody (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:242:37)
at importRequest (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:173:11)
at tags.forEach (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:129:21)
(node:38053) UnhandledPromiseRejectionWarning: Unhandled promise
rejection. This error originated either by throwing inside of an async
function without a catch block, or …Run Code Online (Sandbox Code Playgroud) 我有一个带有 SpringBoot2 和 Junit5 的应用程序,现在我正在尝试进行测试。我有一个名为 OrderService 的类,如下所示:
@Component
public class OrderService {
@Value("#{'${food.requires.box}'.split(',')}")
private List<String> foodRequiresBox;
@Value("#{'${properties.prioritization}'.split(',')}")
private List<String> prioritizationProperties;
@Value("${further.distance}")
private Integer slotMeterRange;
@Value("${slot.meters.long}")
private Double slotMetersLong;
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,该类有许多 @Value 注释,用于从 application.properties 文件中提取值。
在 POM 文件中,我有以下依赖项:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>2.0.5.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
在test/resources文件夹中,我有包含以下信息的 application.properties 文件:
properties.prioritization:vip,food
food.requires.box:pizza,cake,flamingo
further.distance:2
slot.meters.long:0.5
Run Code Online (Sandbox Code Playgroud)
测试文件如下所示:
properties.prioritization:vip,food
food.requires.box:pizza,cake,flamingo
further.distance:2
slot.meters.long:0.5
Run Code Online (Sandbox Code Playgroud)
但测试在尝试使用foodRequiresBox时会抛出 …
我在微服务之间使用 Kafka 进行异步调用,我正在使用 Spring Sleuth 进行日志记录。日志没问题,但是当有消息从微服务1到微服务2时,日志的消息有不同的Trace-ID。他们不是必须具有相同的 trace-Id 但具有不同的 SpanId 吗?有什么特别的配置吗?
我有一个Spring Boot Rest API,我一直在工作,上周我添加了Swagger和Swagger-UI.之后,存储库的测试(仅与存储库相关的测试)开始不起作用,当我运行它时,我收到此错误:
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:44)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: …Run Code Online (Sandbox Code Playgroud) 我在SpringBoot应用程序中使用Logback和Logstash。
在logback.xml中,我有一个带有服务名称的属性,如下所示:
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<property name="spring.application.name" calue="service"/>
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>localhost:9600</destination>
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="stash" />
</root>
</configuration>
Run Code Online (Sandbox Code Playgroud)
Logstash conf文件类似于:
input{ tcp{
port=> 9600
host=>logstash
}
}
filter {
grok {
match => {
"message" =>
"^%{TIMESTAMP_ISO8601:timestamp}\s+%{LOGLEVEL:level}\s+%{NUMBER:pid}\s+---\s+\[\s*%{USERNAME:thread}\s*\]\s+%{JAVAFILE:class}\s*:\s*%{DATA:themessage}(?:\n+(?<stacktrace>(?:.|\r|\n)+))?$"
}
}
date {
match => [ "timestamp" , "yyyy-MM-dd HH:mm:ss.SSS" ]
}
mutate {
remove_field => ["@version"]
add_field => {
"appid" => "%{[path]}"
}
add_field => {
"levell" => "level"
} …Run Code Online (Sandbox Code Playgroud) logback logstash spring-boot logstash-logback-encoder logstash-grok
我正在使用功能控制器将 Swagger 添加到我的 Spring Webflux 服务中。首先我收到这个错误:
描述:无法注册在类路径资源 [org/springdoc/webflux/ui/SwaggerConfig.class] 中定义的 bean“swaggerWelcome”。具有该名称的 bean 已在类路径资源 [org/springdoc/webmvc/ui/SwaggerConfig.class] 中定义,并且覆盖被禁用。
行动:
考虑重命名其中一个 bean 或通过设置 spring.main.allow-bean-definition-overriding=true 来启用覆盖
所以我将 spring.main.allow-bean-definition-overriding=true 添加到我的 application.properties 文件中。
现在我收到这个错误:
描述:
org.springdoc.webmvc.ui.SwaggerConfig 中方法 swaggerWebMvcConfigurer 的参数 1 需要一个类型为“org.springdoc.webmvc.ui.SwaggerIndexTransformer”的 bean,但无法找到。
行动:
考虑在配置中定义“org.springdoc.webmvc.ui.SwaggerIndexTransformer”类型的 bean。
Pom 文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company/groupId>
<artifactId>service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- For all mvc and web functions -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency> …Run Code Online (Sandbox Code Playgroud) spring-boot ×6
flyway ×2
spring ×2
spring-mvc ×2
spring-test ×2
swagger ×2
acceptance ×1
angular ×1
api-doc ×1
aws-lambda ×1
docker ×1
h2 ×1
insomnia ×1
junit ×1
junit5 ×1
logback ×1
logstash ×1
npm ×1
openapi ×1
spring-cloud ×1
swagger-2.0 ×1
testing ×1
typescript ×1