小编Biz*_*4ik的帖子

React:validateDOMNesting:#text不能作为<tr>的子项出现

你能解释一下为什么反应显示警告Warning: validateDOMNesting(...): #text cannot appear as a child of <tr>. See Router > RouterContext > CarWashPage > AllCarWashTable > tr > #text.吗?我在标签内看不到任何文字tr

呈现表的代码

export default class AllCarWashTable extends React.Component{

constructor(props) {
    super(props);
    this.generateHeaders = this.generateHeaders.bind(this);
    this.generateRows = this.generateRows.bind(this);
};

static propTypes = {
    cols : React.PropTypes.array.isRequired,
    rows : React.PropTypes.array.isRequired
}

generateHeaders() {
    let cols = this.props.cols;  // [{key, label}]
    return cols.map(function(colData) {
        return <th key={colData.key}> {colData.label} </th>;
    });
}

generateRows() {
    let cols = this.props.cols,  // [{key, …
Run Code Online (Sandbox Code Playgroud)

warnings reactjs

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

NoSuchMethodError:org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass

我有测试导致错误.我试图在IntelliJ Idea中执行它2018.3.2.所有jupiter和junit依赖项都有版本RELEASE

错误全文:

Dec 26, 2018 1:17:17 AM org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID 'junit-jupiter' failed to execute tests
java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass(Ljava/lang/String;)Lorg/junit/platform/commons/function/Try;
at org.junit.jupiter.engine.support.OpenTest4JAndJUnit4AwareThrowableCollector.createAbortedExecutionPredicate(OpenTest4JAndJUnit4AwareThrowableCollector.java:40)
at org.junit.jupiter.engine.support.OpenTest4JAndJUnit4AwareThrowableCollector.<clinit>(OpenTest4JAndJUnit4AwareThrowableCollector.java:30)
at org.junit.jupiter.engine.support.JupiterThrowableCollectorFactory.createThrowableCollector(JupiterThrowableCollectorFactory.java:34)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:68)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Run Code Online (Sandbox Code Playgroud)

测试有以下观点

import biz.Services.msg.BookTimeMsgService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import static org.junit.jupiter.api.Assertions.assertTrue;

@ExtendWith(MockitoExtension.class)
public class MsgReceiverTest {

@Mock
BookTimeMsgService bookTimeMsgService; …
Run Code Online (Sandbox Code Playgroud)

java dependencies intellij-idea junit5 junit-jupiter

21
推荐指数
2
解决办法
9141
查看次数

Redux:在传递给createStore的preloadedState参数中找到意外的键

你可以帮助我例外吗? Unexpected key "userName" found in preloadedState argument passed to createStore. Expected to find one of the known reducer keys instead: "default". Unexpected keys will be ignored.

我发现了这个链接,但它对我没有帮助.我没有看到一些东西,也许这部分来自文档:普通对象与传递给它的键具有相同的形状

你可以把我的错误放在我的榜样上吗?

import React from "react";
import ReactDOM from "react-dom";
import { Provider } from 'react-redux';
import { createStore, combineReducers, applyMiddleware } from 'redux';
import  App from './containers/App.jsx';
import * as reducers from './reducers'
import types from './constants/actions';

const reducer = combineReducers(reducers);

const destination = document.querySelector("#container");

var store = createStore(reducer, …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux

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

ModelMapper:匹配多个源属性层次结构

我无法解决modelMapper错误。您有什么想法吗?

注意:在视图java.sql.Time中没有非参数构造函数,我没有找到比编写转换器更好的方法

org.modelmapper.ConfigurationException: ModelMapper configuration errors:

1) The destination property 
biz.models.CarWash.setSecondShift()/java.util.Date.setTime() matches 
multiple source property hierarchies:

biz.dto.CarWashDTO.getFirstShift()/java.time.LocalTime.getSecond()
biz.dto.CarWashDTO.getSecondShift()/java.time.LocalTime.getSecond()
Run Code Online (Sandbox Code Playgroud)

错误是由此代码造成的

@SpringBootTest
@RunWith(SpringRunner.class)
public class CarWashDTO2CarWash {

@Autowired
protected ModelMapper modelMapper;

@Test
public void testCarWashDTO2CarWash_allFiledShouldBeConverted(){
    CarWashDTO dto = CarWashDTO.builder()
            .name("SomeName")
            .address("SomeAddress")
            .boxCount(2)
            .firstShift(LocalTime.of(9, 0))
            .secondShift(LocalTime.of(20, 0))
            .phoneNumber("5700876")
            .build();

    modelMapper.addConverter((Converter<CarWashDTO, CarWash>) mappingContext -> {
        CarWashDTO source = mappingContext.getSource();
        CarWash destination = mappingContext.getDestination();
        destination.setId(source.getId());
        destination.setFirstShift(source.getFirstShift() == null ? null : Time.valueOf(source.getFirstShift()));
        destination.setSecondShift(source.getSecondShift() == null ? null : Time.valueOf(source.getSecondShift()));
        destination.setEnable(true);
        destination.setAddress(source.getAddress());
        destination.setBoxCount(source.getBoxCount());
        destination.setName(source.getName());
        destination.setDateOfCreation(source.getDateOfCreation());
        return …
Run Code Online (Sandbox Code Playgroud)

java modelmapper

7
推荐指数
3
解决办法
5723
查看次数

如何从以关闭模式创建的影子根中查询选择

我有一个创建的影子根mode: closed

<session-expiration-popup>
  #shadow root (closed)
  <div class="custom-element-root">
    something
  </div>
</session-expiration-popup>
Run Code Online (Sandbox Code Playgroud)

有什么办法可以querySelect从这个影子根源得到一些东西吗?

我试过

const el = document.querySelector('session-expiration-popup')
el.shadowRoot.querySelector(".custom-element-root");
Run Code Online (Sandbox Code Playgroud)

但是,它不起作用,因为shawRootparam 是null用于mode: close

另外,我尝试过el.attachShadow({ mode: "open" }),但这也是导致异常的错误方式(el 元素存在影子根)。

你还有其他建议吗?

javascript shadow-dom

3
推荐指数
1
解决办法
1670
查看次数

使用 AWS Lambda 作为中间件的 AWS API Gateway 代理

我想使用 AWS API Gateway 作为我的后端的单个入口点,它将根据 URL 前缀将请求代理(重定向)到不同的微服务。然而,在进行代理之前,最好有 lambda,它可以检查请求并做出决定是否允许进行代理,或者最好立即做出响应,所以,换句话说,我希望将 AWS lambda 作为中间件。可以做吗?

amazon-web-services aws-lambda aws-api-gateway

3
推荐指数
1
解决办法
1911
查看次数

为什么没有OutOfMemoryError

我无法理解为什么在这段代码中没有OutOfMemoryError

public static void main(String[] args) {
    Object[] ref = new Object[1];
    while (true) {
        ref[0] = new Object[]{ref};
        ref = (Object[]) ref[0];
    }
}
Run Code Online (Sandbox Code Playgroud)

至于我,上面提到的代码必须按以下方式工作:

Start:
   ref = new Object[1];
Loop:
   ref[0] = new Object []{ new Object[1] }
   ref = new Object []{ new Object[1] }
   ref[0] = new Object []{ new Object []{ new Object[1] } }
   ref = new Object []{ new Object []{ new Object[1] } }
Run Code Online (Sandbox Code Playgroud)

我的意思是保存每个新对象的链接,垃圾收集器不能删除未使用的对象,因此必须有OutOfMemoryError.但如果代码运行,它将工作年龄...

我不明白或我错在哪里?请解释一下.

java heap

2
推荐指数
1
解决办法
109
查看次数

如何模拟bean并避免NoUniqueBeanDefinitionException

我有基于SpringMVC的webApplication,所有的bean都是通过注释来定义的.今天我尝试为我的控制器编写测试.我把第一个,并试图模拟在这个控制器中使用的服务.我通过以下方式做的所有这些:

1)为测试clientControllerTest-context.xml创建上下文文件

<import resource="classpath:spring-context.xml" />

<bean id="ConnectionDB" name="ConnectionDB" class="org.mockito.Mockito" factory-method="mock">
    <constructor-arg value="biz.podoliako.carwash.services.impl.ConnectDB" />
</bean>
Run Code Online (Sandbox Code Playgroud)

其中spring-context.xml是我的webApplication中使用的主要上下文文件(包括有关真正的ConnectionDB bean的信息)

2)使用以下配置创建测试类

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:controllers/clientControllerTest-context.xml"})
@WebAppConfiguration
Run Code Online (Sandbox Code Playgroud)

运行测试时,捕获NoUniqueBeanDefinitionException异常.我希望spring覆盖bean ConnectionDB,但事实上它发现了两个有一个名字的bean,而spring却无法选择哪一个必须使用.

请解释一下我如何使用我的主要spring-context并模拟其中一个bean进行测试,如果可能的话,可以避免NoUniqueBeanDefinitionException.

注意:我认为使用所有配置进行测试创建上下文是一个坏主意,因此我尝试使用我的主要spring-context.

java spring spring-mvc

2
推荐指数
1
解决办法
815
查看次数