我已经创建了一个登录页面angular2
.它有两个输入字段as userName
和password
.登录中有一个按钮.当我打算为此编写测试用例时loginComponent
,不得不predicate
用来识别button
.这是我的测试用例.
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { LoginComponent } from './login.component';
export class LoginComponentTest {
constructor(public loginComponent: LoginComponent){
this.loginComponent.logIn('Chathura', '1234');
}
}
describe('LoginComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
LoginComponent
],
})
});
const fixture = TestBed.createComponent(LoginComponent);
const button = fixture.query(predicate: Predicate<DebugElement>, scope?: Function) : DebugElement
});
Run Code Online (Sandbox Code Playgroud)
我将通过提供输入值进行测试,然后单击登录按钮,看看接下来会发生什么.
我无法找到正确使用谓词的正确教程.
我尝试使用创建s3桶
aws s3api create-bucket —bucket kubernetes-aws-wthamira-io
它会犯这个错误
调用CreateBucket操作时发生错误(IllegalLocationConstraintException):未指定的位置约束与此请求发送到的区域特定端点不兼容.
我使用aws configure
区域设置并将区域设置为eu-west-1
An error occurred (IllegalLocationConstraintException) when calling
the CreateBucket operation: The unspecified location constraint is
incompatible for the region specific endpoint this request was sent
to.
Run Code Online (Sandbox Code Playgroud)
但是犯同样的错误.我怎么解决这个问题.
我使用osx终端连接aws
我正在尝试更新Spring Boot中的数据源,当数据库名称,密码或主机名等数据库属性在spring配置文件或自定义数据库属性文件中更改时.当属性更改时,应用程序必须通过侦听属性更改来自行更新.
一旦数据库配置发生变化,我就会使用Spring执行器来重启bean.但是用户必须明确地发布重新启动的请求.必须通过监听更改并更新数据源来避免此步骤.
你能告诉我在Spring启动时做到这一点的最佳方法吗?
我将使用 axon 制作 cqrs 应用程序。我尝试将 axon RabbitMq 配置到我的应用程序。如果添加 spring-boot-starter-amqp 和 axon-amqp 会导致此错误。我该如何解决这个问题。
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.931 s <<< FAILURE! - in com.thamira.research.ProductServiceApplicationTests
[ERROR] contextLoads(com.thamira.research.ProductServiceApplicationTests) Time elapsed: 0.007 s <<< ERROR!
java.lang.NoClassDefFoundError: org/springframework/messaging/handler/annotation/support/MessageHandlerMethodFactory
Caused by: java.lang.ClassNotFoundException: org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] ProductServiceApplicationTests.contextLoads » NoClassDefFound org/springframew...
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.136 s …
Run Code Online (Sandbox Code Playgroud) 我使用@Audited annotation作为我的基本模型.我为所有实体扩展了它.但它不起作用.有什么方法我可以使用它
这是我的基本模型
@MappedSuperclass
@Getter
@Setter
@Audited
public abstract class BaseModelObject implements Serializable {
/**
*
*/
private static final long serialVersionUID = 4194525198831057382L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
protected Long id;
}
Run Code Online (Sandbox Code Playgroud)
这是我的模特课
@Entity
public class City extends BaseModelObject {
private static final long serialVersionUID = 1L;
@Column
private String name;
}
Run Code Online (Sandbox Code Playgroud) 我试图将我的注册服务器从"Eureka"更改为"Consul",并将Consul更改为我的配置服务器.使用Consul进行服务发现是成功的.但我无法理解如何获取键/值对选项来引导我的应用程序.我有可能做到这一点吗?
我使用具有以下依赖性的弹簧靴
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这是我的春季启动应用程序ConsuleDemoApplication.class
@EnableDiscoveryClient
@SpringBootApplication
@RestController
public class ConsuleDemoApplication {
@RequestMapping("/")
public String home() {
return "Hello world";
}
public static void main(String[] args) {
SpringApplication.run(ConsuleDemoApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
和我的bootstrap.yml是
spring:
cloud:
consul:
discovery:
healthCheckInterval: 15s
instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
application:
name: consul_demo
Run Code Online (Sandbox Code Playgroud) configuration spring-boot consul microservices spring-cloud-consul
我尝试使用axon 配置cqrs和事件源. SeatReseveCreateCommand工作正常.但SeatReserveUpadateCommand无法正常工作.
这是我的SeatReserve 聚合
@Aggregate
public class SeatReserve {
@AggregateIdentifier
private String id;
private String seatid;
private Date date;
@SuppressWarnings("unused")
private SeatReserve() {
}
@CommandHandler
public SeatReserve(SeatReseveCreateCommand seatReseveCreateCommand) {
apply(new SeatReseveCreateEvent(seatReseveCreateCommand.getMyid(), seatReseveCreateCommand.getSeatId(),
seatReseveCreateCommand.getDate()));
}
@CommandHandler
public SeatReserve(SeatReserveUpadateCommand upadateCommand) {
apply(new SeatReserveUpadateEvent(id, upadateCommand.getSeatId()));
}
@EventSourcingHandler
public void on(SeatReseveCreateEvent seatReseveCreateEvent) {
this.id = seatReseveCreateEvent.getId();
this.seatid = seatReseveCreateEvent.getSeatId();
this.date = seatReseveCreateEvent.getDate();
}
@EventSourcingHandler
public void on(SeatReserveChangeEvent upadateEvent) {
seatid = upadateEvent.getSeatId();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的控制器
@RestController …
Run Code Online (Sandbox Code Playgroud) 我需要对我的后端实施 CSRF 保护。我正在使用以下配置。但应用程序允许没有 CSRF 令牌的 Post 和 Get 请求。
@Slf4j
@EnableWebFluxSecurity
@EnableReactiveMethodSecurity
public class SecurityConfig {
@Bean
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http
.csrf(csrf -> csrf.csrfTokenRepository(CookieServerCsrfTokenRepository.withHttpOnlyFalse()))
.authorizeExchange()
.anyExchange().authenticated()
.and().oauth2ResourceServer().jwt();
return http.build();
}
}
Run Code Online (Sandbox Code Playgroud)
在 HTTP 请求中包含实际的 CSRF 令牌
@ControllerAdvice
public class SecurityControllerAdvice {
@ModelAttribute
Mono<CsrfToken> csrfToken(ServerWebExchange exchange) {
Mono<CsrfToken> csrfToken = exchange.getAttribute(CsrfToken.class.getName());
return csrfToken.doOnSuccess(token -> {
exchange.getAttributes()
.put(CsrfRequestDataValueProcessor.DEFAULT_CSRF_ATTR_NAME, token);
});
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用邮递员的API。但这对我不起作用。
春季版
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.3</version>
<relativePath/>
</parent>
Run Code Online (Sandbox Code Playgroud)
依赖项:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-resource-server</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
<version>RELEASE</version>
</dependency> …
Run Code Online (Sandbox Code Playgroud) spring-boot ×4
spring ×3
axon ×2
cqrs ×2
amazon-s3 ×1
angular ×1
consul ×1
csrf ×1
hibernate ×1
java ×1
kops ×1
kubernetes ×1
rabbitmq ×1
spring-amqp ×1
spring-mvc ×1
testing ×1
typescript ×1
vue.js ×1