我创建了一个路由器链接,如下所示.此路由器链接加载ProductsStartComponent,然后此组件使用ngif而不是通过导航加载其他几个组件.由于以下产品类别链接在所有页面中都可见,所以如果我在到达ngif的某个组件后点击此链接,这不会让我重新开始ProductsStartComponent.
由于我是Angular的新手,我对这种行为的理解是因为所有的值/模型都已设置,这就是为什么它不能导航.我想这可以通过刷新或重新加载页面来实现,但是如何实现.请指教.
在admin.component.html中,定义了路由器链接以进行单击.
回报
<li routerLinkActive="active"><a routerLink="categories"><p>Products Categories</p></a></li>
Run Code Online (Sandbox Code Playgroud)
回报
在app-routing.module.ts中,单击路由器链接时需要加载哪个组件
const appRoutes: Routes = [
{path: 'admin', component: AdminComponent, children: [
{ path: 'dashboard', component: AdminDashboardComponent },
{ path: 'sellers', component: AdminSellersComponent },
{ path: 'categories', component: ProductsStartComponent}
]}]
Run Code Online (Sandbox Code Playgroud)
在product-start.component.html中,首次单击路由器链接时会加载它.现在,如果我点击编辑按钮并移动到其他组件,如果我点击产品类别路由器链接再次,没有任何反应,我希望它重置页面.
<div>
<div *ngIf="!isChildProductClicked; else notClicked" >
<app-admin-products (productId)="received($event)"></app-admin-products>
</div>
<ng-template #notClicked><app-child-products [selProdIndex]=productIndex></app-child-products></ng-template>
</div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试通过创建一个虚拟项目来学习微服务。我在 git 中有一个配置存储库和一个在端口 8888 上运行的配置服务器。它工作正常,因为我可以看到我的设置如下:

现在我有两个微服务项目 1)客户服务和 2)客户帐户服务。客户微服务正常运行,而客户帐户微服务无法启动并抛出以下异常:
*Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: org.h2.Driver
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.11.RELEASE.jar:5.0.11.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583) ~[spring-beans-5.0.11.RELEASE.jar:5.0.11.RELEASE]
... 66 common frames omitted
Caused by: java.lang.IllegalStateException: Cannot load driver class: org.h2.Driver
at org.springframework.util.Assert.state(Assert.java:94) ~[spring-core-5.0.11.RELEASE.jar:5.0.11.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:224) ~[spring-boot-autoconfigure-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:176) ~[spring-boot-autoconfigure-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:43) ~[spring-boot-autoconfigure-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari.dataSource(DataSourceConfiguration.java:83) ~[spring-boot-autoconfigure-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.11.RELEASE.jar:5.0.11.RELEASE]
... …Run Code Online (Sandbox Code Playgroud) 我需要使用 spring 数据 jpa 在 postgres 中将实体类的两列映射为 json。在阅读了多个 stackoverflow 帖子和 baeldung 帖子后,
如何使用 JPA 将映射 JSON 列映射到 Java 对象
https://www.baeldung.com/hibernate-persist-json-object
我做了如下配置。但是,我面临错误“错误:列“标题”的类型为 json,但表达式的类型为不同的字符“
请提供一些解决此问题的指针。
我有一个实体类如下
@Entity
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class Task {
@Id
@GeneratedValue(strategy = IDENTITY)
private Integer id;
private String url;
private String httpMethod;
@Convert(converter = HashMapConverter.class)
@Column(columnDefinition = "json")
private Map<String, String> headers;
@Convert(converter = HashMapConverter.class)
@Column(columnDefinition = "json")
private Map<String, String> urlVariables;
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个测试类来测试实体是否持久化。在运行这个 junit 时,下面的测试用例失败,错误如下
@SpringBootTest
class TaskRepositoryTest {
private static Task randomTask …Run Code Online (Sandbox Code Playgroud) 我在为控制器运行 junit 时遇到以下错误。我已经将 content-type 设置为 Json,但错误仍然相同。有什么建议可能是什么问题吗?
错误是
java.lang.AssertionError: expectation "expectNext({response=employee saved Successfully})" failed (expected: onNext({response=employee saved Successfully}); actual: onError(org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'application/octet-stream' not supported for bodyType=java.util.Map<java.lang.String, java.lang.String>))
Run Code Online (Sandbox Code Playgroud)
控制器是
@Slf4j
@Controller
@RequiredArgsConstructor
public class EmployeeController {
private final EmployeeService employeeService;
@PostMapping(path ="/employees",produces = APPLICATION_JSON_VALUE)
public @ResponseBody Mono<Map<String, String>> saveEmployees(@RequestBody List<EmployeeDto> employeeDtos) {
log.info("Received request to save employees [{}]", employeeDtos);
return employeeService.saveEmployee(employeeDtos);
}
}
Run Code Online (Sandbox Code Playgroud)
服务等级如下:
@Service
@Slf4j
@RequiredArgsConstructor
public class EmployeeService {
private final WebClient webClient;
public Mono<Map<String, String>> saveEmployees(List<EmployeeDto> employeeDtos) { …Run Code Online (Sandbox Code Playgroud) 我有一个巨大的消息文件,我需要分成不同语言的多个文件.例如 :
我为英语语言环境创建了一个文件夹,即en和另一个用于法语区域设置的文件夹,fr在conf文件夹中.包含messages1_en.properties和messages2_en.properties fr包含messages1_fr.properties和messages2_fr.properties
如何在我的视图中访问这些属性文件.
谢谢
在我的HTML页面中存在多个组件,在按Tab键按钮时,焦点设置为某些组件(不按顺序).如何阻止标签将焦点放在整个页面上的任何组件上?使用最外层div id的html页面我们可以阻止选项卡将焦点放在任何组件和位置栏上吗?
我已经添加了jsfiddle (demo),即使我没有使用tabindex,但仍然专注于告诉我如何禁用tab click.
$(document).on('keydown', function(event) {
if (event.keyCode == 9) { //tab pressed
event.preventDefault(); // stops its action
}
});
Run Code Online (Sandbox Code Playgroud) 我正在按照以下链接编写端到端的春季批处理作业测试。
https://docs.spring.io/spring-batch/docs/current/reference/html/testing.html#endToEndTesting
这告诉使用 @RunWith(SpringRunner.class) 注释您的测试类,这是 Junit4 功能,我的测试用例使用 junit5 的老式引擎工作正常。
由于我的其他非批处理相关测试用例在 jupiter 引擎上运行,因此我想在我的端到端 spring 批处理作业测试中使用相同的测试用例。如果我用@ExtendWith(SpringExtension.class) 替换@RunWith(SpringRunner.class),我可以看到没有自动装配的字段被实例化并且具有空值。
由于我是春季批次和木星的新手,我无法理解出了什么问题。
任何指针将不胜感激
junit 测试用例示例代码
import com.zaxxer.hikari.HikariDataSource;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.configuration.annotation.BatchConfigurer;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.batch.test.JobRepositoryTestUtils;
import org.springframework.batch.test.context.SpringBatchTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit4.SpringRunner;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import static org.assertj.core.api.Assertions.assertThat;
@Slf4j
@Testcontainers
@SpringBatchTest
@SpringBootTest
@RunWith(SpringRunner.class)
//@ExtendWith(SpringExtension.class) …Run Code Online (Sandbox Code Playgroud) spring-boot ×3
html ×2
spring ×2
angular ×1
jackson ×1
java ×1
javascript ×1
jquery ×1
json ×1
junit5 ×1
liquibase ×1
octetstring ×1
postgresql ×1
spring-batch ×1
spring-mvc ×1