问:
NoSuchMethodError: org.springframework.data.util.TypeInformation.isSubTypeOf(Ljava/lang/Class;)Z
I am using Spring Data Elasticsearch with Elasticsearch version 7.4.
Maven:

```<code>    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        <version>2.1.7.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-elasticsearch</artifactId>
        <version>4.0.0.BUILD-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-commons</artifactId>
        <version>2.1.10.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>7.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>7.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-client</artifactId>
        <version>7.4.0</version>
    </dependency>
</code>```

Model

```<code>@AllArgsConstructor
@NoArgsConstructor
@Data
@Document(indexName = "address", createIndex = true)
public class Address {
    @Id
    private String id;
    private String fullAddress;

    @Field(type = FieldType.Nested, store = true)
    private List<Entry> parts;

    public Address(String fullAddress) {
        this.fullAddress = fullAddress;
    }

    public Address(String fullAddress, List<Entry> entryList) {
        this.fullAddress = fullAddress;
        this.parts = entryList;
    }
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Entry {
    private String aoid;
    private String aoGuid;
    private String code;
    private String offName;
    private String parentGuid;
    private String shortName;
    @Field(type = FieldType.Integer)
    private Integer aoLevel;
    private String postalCode;
}
</code>```

Repository:

```<code>@Repository
public interface AddressElasticRepository extends ElasticsearchRepository<Address, String> {
    List<Address> findByFullAddressContains(String fullAddress);
}
</code>```

Service

```<code>@Service
public class SearchServiceImpl implements SearchService {
    private final AddressElasticRepository addressElasticRepository;

    public SearchServiceImpl(AddressElasticRepository addressElasticRepository) {
        this.addressElasticRepository = addressElasticRepository;
    }

    @Override
    public List<Document> search(String query) {
        List<Address> all = addressElasticRepository.findByFullAddressContains(query);
        all.forEach(it -> log.info("-- " + it.getFullAddress()));

        return null;
    }

    @Override
    public void save(Address address) {
        addressElasticRepository.save(address);
    }
}
</code>```

Controller:

```<code>@Controller
public class SearchController {
    private final SearchService searchService;

    public SearchController(SearchService searchService) {
        this.searchService = searchService;
    }

    @RequestMapping(value = "/api/v1/fias/search", method = GET)
    public List<Document> search(@RequestParam String query) {
        return searchService.search(query);
    }
}
</code>```

When I do a search: localhost:8189/api/v1/fias/search?query=Moscow I get an error:

java.lang.NoSuchMethodError:
  org.springframework.data.util.TypeInformation.isSubTypeOf(Ljava/lang/Class;)Z

The error occurs on the line (SearchServiceImpl.java:23): List  all = addressElasticRepository.findByFullAddressContains (query);

How to fix it?

UPD: Full StackTrace

java.lang.NoSuchMethodError:
  org.springframework.data.util.TypeInformation.isSubTypeOf(Ljava/lang/Class;)Z
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.createCollectionForValue(MappingElasticsearchConverter.java:675)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.readCollectionValue(MappingElasticsearchConverter.java:362)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.readValue(MappingElasticsearchConverter.java:345)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter$ElasticsearchPropertyValueProvider.getPropertyValue(MappingElasticsearchConverter.java:876)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.readProperties(MappingElasticsearchConverter.java:319)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.readEntity(MappingElasticsearchConverter.java:267)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.read(MappingElasticsearchConverter.java:247)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.mapDocument(MappingElasticsearchConverter.java:220)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.read(MappingElasticsearchConverter.java:188)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.lambda$read$1(MappingElasticsearchConverter.java:169)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
  ~[na:1.8.0_201]   at
  java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
  ~[na:1.8.0_201]   at
  java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
  ~[na:1.8.0_201]   at
  java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
  ~[na:1.8.0_201]   at
  java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
  ~[na:1.8.0_201]   at
  java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
  ~[na:1.8.0_201]   at
  java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
  ~[na:1.8.0_201]   at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.read(MappingElasticsearchConverter.java:170)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.search(ElasticsearchRestTemplate.java:244)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.repository.query.ElasticsearchPartQuery.execute(ElasticsearchPartQuery.java:106)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:605)
  ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]  at
  org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595)
  ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]  at
  org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595)
  ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]  at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
  ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]  at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
  ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]  at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  com.sun.proxy.$Proxy120.findByFullAddressContains(Unknown Source)
  ~[na:na]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
  Method) ~[na:1.8.0_201]   at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  ~[na:1.8.0_201]   at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  ~[na:1.8.0_201]   at java.lang.reflect.Method.invoke(Method.java:498)
  ~[na:1.8.0_201]   at
  org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:338)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
  ~[spring-tx-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  com.sun.proxy.$Proxy120.findByFullAddressContains(Unknown Source)
  ~[na:na]  at
  ru.evolenta.server.service.impl.SearchServiceImpl.search(SearchServiceImpl.java:23)
  ~[classes/:na]    at
  ru.evolenta.server.controller.SearchController.search(SearchController.java:27)
  ~[classes/:na]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
  Method) ~[na:1.8.0_201]   at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  ~[na:1.8.0_201]   at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  ~[na:1.8.0_201]   at java.lang.reflect.Method.invoke(Method.java:498)
  ~[na:1.8.0_201]   at
  org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:870)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:776)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:870)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  ~[tomcat-embed-websocket-8.5.28.jar:8.5.28]   at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:158)
  ~[spring-boot-actuator-2.0.0.RELEASE.jar:2.0.0.RELEASE]   at
  org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:126)
  ~[spring-boot-actuator-2.0.0.RELEASE.jar:2.0.0.RELEASE]   at
  org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:111)
  ~[spring-boot-actuator-2.0.0.RELEASE.jar:2.0.0.RELEASE]   at
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:84)
  ~[spring-boot-actuator-2.0.0.RELEASE.jar:2.0.0.RELEASE]   at
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  ru.evolenta.server.filters.SimpleCORSFilter.doFilter(SimpleCORSFilter.java:51)
  ~[classes/:na]    at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:209)
  ~[spring-security-web-5.0.3.RELEASE.jar:5.0.3.RELEASE]    at
  org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
  ~[spring-security-web-5.0.3.RELEASE.jar:5.0.3.RELEASE]    at
  org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  [na:1.8.0_201]    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  [na:1.8.0_201]    at
  org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]

UPD 2: Error in spring-data-commons version. The isSubTypeOf method appeared after version 2.2. If I upgrade, the application does not start, here is the stack trace:

java.lang.NoSuchFieldError: IMPORT_BEAN_NAME_GENERATOR    at
  org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport.java:78)
  ~[spring-data-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]    at
  org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromRegistrars$0(ConfigurationClassBeanDefinitionReader.java:360)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
  ~[na:1.8.0_201]   at
  org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:359)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
  ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]    at
  org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
  [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]     at
  org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)
  [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]     at
  org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
  [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]     at
  org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
  [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]     at
  org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
  [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]     at
  ru.evolenta.server.CoreFiasApplication.main(CoreFiasApplication.java:21)
  [classes/:na]

答:
Spring Data Elasticsearch 4.0.0.BUILD-SNAPSHOT is built against Spring Data Commons 2.3.0.BUILD-SNAPSHOT. You should not use the older commons 2.1.10.RELEASE here.

Out of curiosity: Why do you use a CustomElasticSearchConverter?

As for the configuration, check https://docs.spring.io/spring-data/elasticsearch/docs/4.0.0.M3/reference/html/#elasticsearch.clients.rest.

And when doing custom configuration,

```<code>@SpringBootApplication(exclude = {ElasticsearchAutoConfiguration.class})
</code>```

is the right way to go.

Edit:

spring-data-elasticsearch 4.0.0.BUILD_SNAPSHOT will not work with spring-data-commons 2.0.5. RepositoryBeanDefinitionRegistrarSupport.IMPORT_BEAN_NAME_GENERATOR was introduced in Spring 5.2.

So spring-data-elasticsearch 4.0 needs spring-data-commons 2.3 and Spring 5.2.3. Not having these versions will lead to the errors you see.

Body:
I am using Spring Data Elasticsearch with Elasticsearch version 7.4.
Maven:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        <version>2.1.7.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-elasticsearch</artifactId>
        <version>4.0.0.BUILD-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-commons</artifactId>
        <version>2.1.10.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>7.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>7.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-client</artifactId>
        <version>7.4.0</version>
    </dependency>

Model

@AllArgsConstructor
@NoArgsConstructor
@Data
@Document(indexName = "address", createIndex = true)
public class Address {
    @Id
    private String id;
    private String fullAddress;

    @Field(type = FieldType.Nested, store = true)
    private List<Entry> parts;

    public Address(String fullAddress) {
        this.fullAddress = fullAddress;
    }

    public Address(String fullAddress, List<Entry> entryList) {
        this.fullAddress = fullAddress;
        this.parts = entryList;
    }
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Entry {
    private String aoid;
    private String aoGuid;
    private String code;
    private String offName;
    private String parentGuid;
    private String shortName;
    @Field(type = FieldType.Integer)
    private Integer aoLevel;
    private String postalCode;
}

Repository:

@Repository
public interface AddressElasticRepository extends ElasticsearchRepository<Address, String> {
    List<Address> findByFullAddressContains(String fullAddress);
}

Service

@Service
public class SearchServiceImpl implements SearchService {
    private final AddressElasticRepository addressElasticRepository;

    public SearchServiceImpl(AddressElasticRepository addressElasticRepository) {
        this.addressElasticRepository = addressElasticRepository;
    }

    @Override
    public List<Document> search(String query) {
        List<Address> all = addressElasticRepository.findByFullAddressContains(query);
        all.forEach(it -> log.info("-- " + it.getFullAddress()));

        return null;
    }

    @Override
    public void save(Address address) {
        addressElasticRepository.save(address);
    }
}

Controller:

@Controller
public class SearchController {
    private final SearchService searchService;

    public SearchController(SearchService searchService) {
        this.searchService = searchService;
    }

    @RequestMapping(value = "/api/v1/fias/search", method = GET)
    public List<Document> search(@RequestParam String query) {
        return searchService.search(query);
    }
}

When I do a search: localhost:8189/api/v1/fias/search?query=Moscow I get an error:

java.lang.NoSuchMethodError:
  org.springframework.data.util.TypeInformation.isSubTypeOf(Ljava/lang/Class;)Z

The error occurs on the line (SearchServiceImpl.java:23): List  all = addressElasticRepository.findByFullAddressContains (query);

How to fix it?

UPD: Full StackTrace

java.lang.NoSuchMethodError:
  org.springframework.data.util.TypeInformation.isSubTypeOf(Ljava/lang/Class;)Z
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.createCollectionForValue(MappingElasticsearchConverter.java:675)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.readCollectionValue(MappingElasticsearchConverter.java:362)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.readValue(MappingElasticsearchConverter.java:345)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter$ElasticsearchPropertyValueProvider.getPropertyValue(MappingElasticsearchConverter.java:876)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.readProperties(MappingElasticsearchConverter.java:319)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.readEntity(MappingElasticsearchConverter.java:267)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.read(MappingElasticsearchConverter.java:247)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.mapDocument(MappingElasticsearchConverter.java:220)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.read(MappingElasticsearchConverter.java:188)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.lambda$read$1(MappingElasticsearchConverter.java:169)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
  ~[na:1.8.0_201]   at
  java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
  ~[na:1.8.0_201]   at
  java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
  ~[na:1.8.0_201]   at
  java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
  ~[na:1.8.0_201]   at
  java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
  ~[na:1.8.0_201]   at
  java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
  ~[na:1.8.0_201]   at
  java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
  ~[na:1.8.0_201]   at
  org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.read(MappingElasticsearchConverter.java:170)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.search(ElasticsearchRestTemplate.java:244)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.elasticsearch.repository.query.ElasticsearchPartQuery.execute(ElasticsearchPartQuery.java:106)
  ~[spring-data-elasticsearch-4.0.0.BUILD-20200217.043541-321.jar:4.0.0.BUILD-SNAPSHOT]
    at
  org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:605)
  ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]  at
  org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595)
  ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]  at
  org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595)
  ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]  at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
  ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]  at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
  ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]  at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  com.sun.proxy.$Proxy120.findByFullAddressContains(Unknown Source)
  ~[na:na]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
  Method) ~[na:1.8.0_201]   at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  ~[na:1.8.0_201]   at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  ~[na:1.8.0_201]   at java.lang.reflect.Method.invoke(Method.java:498)
  ~[na:1.8.0_201]   at
  org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:338)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
  ~[spring-tx-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
  ~[spring-aop-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  com.sun.proxy.$Proxy120.findByFullAddressContains(Unknown Source)
  ~[na:na]  at
  ru.evolenta.server.service.impl.SearchServiceImpl.search(SearchServiceImpl.java:23)
  ~[classes/:na]    at
  ru.evolenta.server.controller.SearchController.search(SearchController.java:27)
  ~[classes/:na]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
  Method) ~[na:1.8.0_201]   at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  ~[na:1.8.0_201]   at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  ~[na:1.8.0_201]   at java.lang.reflect.Method.invoke(Method.java:498)
  ~[na:1.8.0_201]   at
  org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:870)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:776)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:870)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
  ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]  at
  javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  ~[tomcat-embed-websocket-8.5.28.jar:8.5.28]   at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:158)
  ~[spring-boot-actuator-2.0.0.RELEASE.jar:2.0.0.RELEASE]   at
  org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:126)
  ~[spring-boot-actuator-2.0.0.RELEASE.jar:2.0.0.RELEASE]   at
  org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:111)
  ~[spring-boot-actuator-2.0.0.RELEASE.jar:2.0.0.RELEASE]   at
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:84)
  ~[spring-boot-actuator-2.0.0.RELEASE.jar:2.0.0.RELEASE]   at
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  ru.evolenta.server.filters.SimpleCORSFilter.doFilter(SimpleCORSFilter.java:51)
  ~[classes/:na]    at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:209)
  ~[spring-security-web-5.0.3.RELEASE.jar:5.0.3.RELEASE]    at
  org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
  ~[spring-security-web-5.0.3.RELEASE.jar:5.0.3.RELEASE]    at
  org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  ~[spring-web-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
  ~[tomcat-embed-core-8.5.28.jar:8.5.28]    at
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  [na:1.8.0_201]    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  [na:1.8.0_201]    at
  org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  [tomcat-embed-core-8.5.28.jar:8.5.28]     at
  java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]

UPD 2: Error in spring-data-commons version. The isSubTypeOf method appeared after version 2.2. If I upgrade, the application does not start, here is the stack trace:

java.lang.NoSuchFieldError: IMPORT_BEAN_NAME_GENERATOR    at
  org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport.java:78)
  ~[spring-data-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]    at
  org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromRegistrars$0(ConfigurationClassBeanDefinitionReader.java:360)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
  ~[na:1.8.0_201]   at
  org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:359)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
  ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]     at
  org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
  ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]    at
  org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
  [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]     at
  org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)
  [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]     at
  org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
  [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]     at
  org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
  [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]     at
  org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
  [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]     at
  ru.evolenta.server.CoreFiasApplication.main(CoreFiasApplication.java:21)
  [classes/:na]

Body:
Spring Data Elasticsearch 4.0.0.BUILD-SNAPSHOT is built against Spring Data Commons 2.3.0.BUILD-SNAPSHOT. You should not use the older commons 2.1.10.RELEASE here.

Out of curiosity: Why do you use a CustomElasticSearchConverter?

As for the configuration, check https://docs.spring.io/spring-data/elasticsearch/docs/4.0.0.M3/reference/html/#elasticsearch.clients.rest.

And when doing custom configuration,

@SpringBootApplication(exclude = {ElasticsearchAutoConfiguration.class})

is the right way to go.

Edit:

spring-data-elasticsearch 4.0.0.BUILD_SNAPSHOT will not work with spring-data-commons 2.0.5. RepositoryBeanDefinitionRegistrarSupport.IMPORT_BEAN_NAME_GENERATOR was introduced in Spring 5.2.

So spring-data-elasticsearch 4.0 needs spring-data-commons 2.3 and Spring 5.2.3. Not having these versions will lead to the errors you see.


来源: stackexchange

问:
Select Business Process Flow Stage onChange of a Field Value
I am trying to update a business process flow stage using Workflow or JavaScript.

First I tried with JavaScript using below method,

```<code>Xrm.Page.data.process.moveNext(onSetActiveStage);
</code>```

But the problem with this method is if the active stage is greater than the required selected stage then moveNext logic will not work.

I know I can use movePrevious as well but it will be another overhead as sometime the active stage will be before the required stage and sometime it will be after.

The other option for me was on some field change I can use a workflow to activate or select a stage on business process flow.

For that I created a workflow and selected my BPF as my entity and selected a field on Process Change.

And inside my Set Properties, I set Active stage as the required stage which I want to mark as active.

The above logic is not working for me on change of the field.

I am new to BPF, please bear with me if I am making some basic mistake.

答:
If you are following this blogpost, the comments below the post says - it's not working/triggering for custom BPF and you have to refresh the form to see the changes. Make sure if this is what affecting you.

Also you can un-check the "Workflow Job Retention" checkbox for troubleshooting to see if its triggering or not.

Btw, your design seems to be little confusing, required stage before/after active stage does not makes sense. You may need to add the different branch and "Data step" to make it required in different scenarios.

If this is not feasible, then try to use scripting to set the active stage or plugin/custom action to set the stage on your trigger.

ContentLicense: CC BY-SA 4.0

Body:
I am trying to update a business process flow stage using Workflow or JavaScript.

First I tried with JavaScript using below method,

Xrm.Page.data.process.moveNext(onSetActiveStage);

But the problem with this method is if the active stage is greater than the required selected stage then moveNext logic will not work.

I know I can use movePrevious as well but it will be another overhead as sometime the active stage will be before the required stage and sometime it will be after.

The other option for me was on some field change I can use a workflow to activate or select a stage on business process flow.

For that I created a workflow and selected my BPF as my entity and selected a field on Process Change.

And inside my Set Properties, I set Active stage as the required stage which I want to mark as active.

The above logic is not working for me on change of the field.

I am new to BPF, please bear with me if I am making some basic mistake.


问:
How does Linked List function to make another linked list with different order of elements. Explanation please
```<code>struct node* question4(struct node *list){ //list = 66, 9, 14, 52, 87, 14, 17
      struct node* a = list; //a = 66, 9, 14, 52, 87, 14, 17 pointing to head (66)
      struct node* b = list; //b = 66, 9, 14, 52, 87, 14, 17 pointing to head (66)
      struct node* c;
      if(a == NULL) return NULL; // a is not NULL it's pointing to 66
      while(a->next != NULL) // run until a points to the last element (17)
            a = a->next;
      a->next = b; //next element of 17 points to b (which is 66).
      c = b->next; // c points to what b is pointing to next which is 9.
      b -> next = NULL; // next element of b is NULL(instead of 14). what happens here?
      return c;
}
</code>```

So a is connected to b. so a's element goes like this?
66->9->14->52->87->14->17->66->9->14->52->87->14->17

and b is just 66->9->NULL?

c is 9->14->52->87->14->17? OR 9->14->52->87->14->17->66 ? why?

I'm currently learning about linked list, thank you guys for your help!

答:
This code is used to rotate a singly-linked list to the right one node.

Let's consider this statement

```<code>c = b->next;
</code>```

the pointer b after this declaration

```<code>struct node* b = list
</code>```

points to the element with the value 66

```<code>b = 66, 9, 14, 52, 87, 14, 17
</code>```

So c points to the next element with the value 9` (b->next).

Then after this statement

```<code>b -> next = NULL;
</code>```

we have

```<code>66, NULL, 9, 14, 52, 87, 14, 17
          ^
          |
          c
</code>```

But after the previous code snippet

```<code>  while(a->next != NULL) // run until a points to the last element (17)
        a = a->next;
  a->next = b
</code>```

the last mode with the value 17 points to the previously first node with the value 66.

As a result you have

c =  9, 14, 52, 87, 14, 17, 66, NULL

Body:
struct node* question4(struct node *list){ //list = 66, 9, 14, 52, 87, 14, 17
      struct node* a = list; //a = 66, 9, 14, 52, 87, 14, 17 pointing to head (66)
      struct node* b = list; //b = 66, 9, 14, 52, 87, 14, 17 pointing to head (66)
      struct node* c;
      if(a == NULL) return NULL; // a is not NULL it's pointing to 66
      while(a->next != NULL) // run until a points to the last element (17)
            a = a->next;
      a->next = b; //next element of 17 points to b (which is 66).
      c = b->next; // c points to what b is pointing to next which is 9.
      b -> next = NULL; // next element of b is NULL(instead of 14). what happens here?
      return c;
}

So a is connected to b. so a's element goes like this?
66->9->14->52->87->14->17->66->9->14->52->87->14->17

and b is just 66->9->NULL?

c is 9->14->52->87->14->17? OR 9->14->52->87->14->17->66 ? why?

I'm currently learning about linked list, thank you guys for your help!

Body:
This code is used to rotate a singly-linked list to the right one node.

Let's consider this statement

c = b->next;

the pointer b after this declaration

struct node* b = list

points to the element with the value 66

b = 66, 9, 14, 52, 87, 14, 17

So c points to the next element with the value 9` (b->next).

Then after this statement

b -> next = NULL;

we have

66, NULL, 9, 14, 52, 87, 14, 17
          ^
          |
          c

But after the previous code snippet

  while(a->next != NULL) // run until a points to the last element (17)
        a = a->next;
  a->next = b

the last mode with the value 17 points to the previously first node with the value 66.

As a result you have

c =  9, 14, 52, 87, 14, 17, 66, NULL


问:
Mapping through array of objects to display images
I'm trying to map through an array of objects to display the images. Here is my code:

```<code>import React from 'react';
import photos from '../photo-store';

class Landing extends React.Component {
  render() {
    const photoDisplay = Object.keys(photos).map((photo, i) => {
      return <img key={i} src={`.${photos[photo][i].src}`} alt='headshot'/>
    })
    console.log('photoDisplay', photoDisplay)
    return (
      <div>
        <p>Photos will go here</p>
        {photoDisplay}
      </div>
    )
  }
}

export default Landing;
</code>```

The src value is correct when I console.log, but for some reason I'm just getting my alt information rendering, and it's not going through all of the objects in the array. Any pointers on what might be happening here would be awesome. Thanks in advance for your help!

Here is a snippet of what is in "photos":

```<code>"photos": [
    {
      id: 1,
      name: "AmberB",
      src: "./images/AmberB.jpg"
    },
    {
      id: 2,
      name: "AmberR",
      src: "./images/AmberR.jpg"
    }
  ]
}
</code>```

答:
You made a small mistake in the return statement. If you have for src attribute the ${photos[photo].src} instead of photos[photo][i].src then it should work.

```<code>const photoDisplay = Object.keys(photos).map((photo, i) => {
   return <img key={i} src={`${photos[photo].src}`} alt='headshot'/>
})
</code>```

Please also consider removing the . as well but not sure about that.

I hope that helps!

Body:
I'm trying to map through an array of objects to display the images. Here is my code:

import React from 'react';
import photos from '../photo-store';

class Landing extends React.Component {
  render() {
    const photoDisplay = Object.keys(photos).map((photo, i) => {
      return <img key={i} src={`.${photos[photo][i].src}`} alt='headshot'/>
    })
    console.log('photoDisplay', photoDisplay)
    return (

Photos will go here

        {photoDisplay}

    )
  }
}

export default Landing;

The src value is correct when I console.log, but for some reason I'm just getting my alt information rendering, and it's not going through all of the objects in the array. Any pointers on what might be happening here would be awesome. Thanks in advance for your help!

Here is a snippet of what is in "photos":

"photos": [
    {
      id: 1,
      name: "AmberB",
      src: "./images/AmberB.jpg"
    },
    {
      id: 2,
      name: "AmberR",
      src: "./images/AmberR.jpg"
    }
  ]
}

Body:
You made a small mistake in the return statement. If you have for src attribute the ${photos[photo].src} instead of photos[photo][i].src then it should work.

const photoDisplay = Object.keys(photos).map((photo, i) => {
   return <img key={i} src={`${photos[photo].src}`} alt='headshot'/>
})

Please also consider removing the . as well but not sure about that.

I hope that helps!


问:
Authenticating a REST API with Cognito using AWS Amplify & Android
I am currently trying to configure a REST API I added using AWS Amplify. I have already configured user authentication in which users can sign-up and sign-in by following the steps outlined in the authentication docs. I then added a REST API using the api steps.

At the moment, I am just trying to retrieve a list of items from DynamoDB. The api is successful when I test it on the aws console, however, when I make the call from my android api, it returns the following error:

```<code>{"message":"Authorization header requires 'Credential' parameter. Authorization header requires 'Signature' parameter. Authorization header requires 'SignedHeaders' parameter. Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header. Authorization=[a long string of characters]
</code>```

I understand that amplify automatically sets the API to be restricted using AWS_IAM, which I think is why the above message is returned. I am trying to get it to authenticate using the user pools I setup before with the authentication steps. The code in my android that app that makes the call to the API is as follows:

RestOptions options = new RestOptions("/models");

Amplify.API.get("modelsapi", options, new ResultListener<RestResponse>() {
    @Override
    public void onResult(RestResponse restResponse) {
        Log.i(TAG, restResponse.toString());
        Log.i(TAG, restResponse.getData().asString());
    }

    @Override
    public void onError(Throwable throwable) {
        Log.e(TAG, throwable.toString());
    }
});
```

<p>Do I need to setup a Authorizer on AWS api console? And if so, How do I pass the authorization header with the user token. I have a seen a few responses from people using react native but not with android: AWS-amplify Including the cognito Authorization header in the request</p>

<p>The function which the Api invokes is as follows if needed:</p>

<pre class="lang-js prettyprint-override"><code>app.get(path, function(req, res) {

  let queryParams = {
    TableName: tableName
  }

  dynamodb.scan(queryParams, (err, data) => {
    if (err) {
      res.statusCode = 500;
      res.json({error: 'Could not load items: ' + err});
    } else {
      res.json(data.Items);
    }
  });
});
</code>```

Any points/help would be greatly appreciated! Thanks!

答:
Have figured it out. Even though Amplify is meant to take the credentials automatically when making an API call, it seemed to throw up the unauthorized error anyway. When I tested using the console it worked fine. I had to manually add the authorization header to the Rest options:

RestOptions options = RestOptions.builder()
                .addPath("models")
                .addHeader("Authorization", token.getTokenString())
                .build();
```

Body:
I am currently trying to configure a REST API I added using AWS Amplify. I have already configured user authentication in which users can sign-up and sign-in by following the steps outlined in the authentication docs. I then added a REST API using the api steps.

At the moment, I am just trying to retrieve a list of items from DynamoDB. The api is successful when I test it on the aws console, however, when I make the call from my android api, it returns the following error:

{"message":"Authorization header requires 'Credential' parameter. Authorization header requires 'Signature' parameter. Authorization header requires 'SignedHeaders' parameter. Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header. Authorization=[a long string of characters]

I understand that amplify automatically sets the API to be restricted using AWS_IAM, which I think is why the above message is returned. I am trying to get it to authenticate using the user pools I setup before with the authentication steps. The code in my android that app that makes the call to the API is as follows:

RestOptions options = new RestOptions("/models");

Amplify.API.get("modelsapi", options, new ResultListener<RestResponse>() {
    @Override
    public void onResult(RestResponse restResponse) {
        Log.i(TAG, restResponse.toString());
        Log.i(TAG, restResponse.getData().asString());
    }

    @Override
    public void onError(Throwable throwable) {
        Log.e(TAG, throwable.toString());
    }
});

Do I need to setup a Authorizer on AWS api console? And if so, How do I pass the authorization header with the user token. I have a seen a few responses from people using react native but not with android: AWS-amplify Including the cognito Authorization header in the request

The function which the Api invokes is as follows if needed:

app.get(path, function(req, res) {

  let queryParams = {
    TableName: tableName
  }

  dynamodb.scan(queryParams, (err, data) => {
    if (err) {
      res.statusCode = 500;
      res.json({error: 'Could not load items: ' + err});
    } else {
      res.json(data.Items);
    }
  });
});

Any points/help would be greatly appreciated! Thanks!


问:
jw player skins xml and swf
i have jw player on in project and it work fine. and when i download some of skins they work fine.

Problem is some of the skins is not working, and the folder on netbeans show me that is is unrecognized even though i download it from the official website.

Does anyone know how i can put a XML skin .

答:
i found out how just put the .swf in the mediaplayer folder and then i used this code in the helper. and the same thing for XML files.</p>

```<code>public function Mediaplayer($VideoPath, $width, $height) {
    return '<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="' . $width . '" height="' . $height . '">
    <param name="movie" value="/mediaplayer/player.swf" />
            <param name="wmode" value="transparent" />
    <param name="allowfullscreen" value="true" />
    <param name="allowscriptaccess" value="always" />
    <param name="flashvars" value="file=' . $VideoPath . '&image=' . str_replace('.flv', '.jpg', str_replace('/flv/', '/thumb/', $VideoPath)) . '&skin='.URL_ADDRESS.'/mediaplayer/comet.swf"'.logo.file ( 'test' ).' />
    <embed
        type="application/x-shockwave-flash"
        id="player2"
        name="player2"
        src="/mediaplayer/player.swf"
        width="' . $width . '"
        height="' . $height . '"
        allowscriptaccess="always"
        allowfullscreen="true"
        flashvars="file=' . $VideoPath . '&image=' . str_replace('.flv', '.jpg', str_replace('/flv/', '/thumb/', $VideoPath)) . '&skin='.URL_ADDRESS.'/mediaplayer/comet.swf"
    />  </object>';
}
</code>```

ContentLicense: CC BY-SA 3.0

Title: jw player skins xml and swf

Body:
i found out how just put the .swf in the mediaplayer folder and then i used this code in the helper. and the same thing for XML files.

public function Mediaplayer($VideoPath, $width, $height) {
    return '<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="' . $width . '" height="' . $height . '">
    <param name="movie" value="/mediaplayer/player.swf" />
            <param name="wmode" value="transparent" />
    <param name="allowfullscreen" value="true" />
    <param name="allowscriptaccess" value="always" />
    <param name="flashvars" value="file=' . $VideoPath . '&image=' . str_replace('.flv', '.jpg', str_replace('/flv/', '/thumb/', $VideoPath)) . '&skin='.URL_ADDRESS.'/mediaplayer/comet.swf"'.logo.file ( 'test' ).' />
    <embed
        type="application/x-shockwave-flash"
        id="player2"
        name="player2"
        src="/mediaplayer/player.swf"
        width="' . $width . '"
        height="' . $height . '"
        allowscriptaccess="always"
        allowfullscreen="true"
        flashvars="file=' . $VideoPath . '&image=' . str_replace('.flv', '.jpg', str_replace('/flv/', '/thumb/', $VideoPath)) . '&skin='.URL_ADDRESS.'/mediaplayer/comet.swf"
    />  </object>';
}


问:
signInWithPopup vs linkWithPopup in firebase
What are the differences between signInWithPopup vs linkWithPopup in firebase? From the API reference, I can barely get anything useful regarding the differences. </p>

答:
They are completely different operations.

signInWithPopup is for signing in an existing user through an authentication provider that can use popup windows to handle the interactions with the user. The alternative with signInWithRedirect, which does not use a popup.

linkWithPopup is for linking additional authentication providers to an existing Firebase auth account using a popup window. The alternative is linkWithRedirect, which does not use a popup.

I suggest reading through the documentation for signing in users (Google, Facebook), and linking additional accounts.


问:
replacement for std::binary_function
std::binary_function is deprecated now and is going to be deleted in c++17. I searched on different publications, but I couldn't find a exact way to replace it. I'd like to know how should I write the following code in c++11 style.

template <class T>
inline T absolute(const T &x) {
    return (x >= 0) ? x : -x;
}

template <class T>
struct absoluteLess : public std::binary_function<T, T, bool> {
    bool operator()(const T &x, const T &y) const {
        return absolute(x) < absolute(y);
    }
};

template <class T>
struct absoluteGreater : public std::binary_function<T, T, bool> {
    bool operator()(T &x, T &y) const {
        return absolute(x) > absolute(y);
    }
};
```
<h3>EDIT</h3>
<p>I'm using the functions in the following way:</p>
<pre class="lang-cpp prettyprint-override"><code>output[j] = *std::max_element(input.begin() + prev,
                              input.begin() + pos,
                              absoluteLess<float>());
</code>```

input and output are std::vectors, inside a for-loop.

答: I believe you're looking for std::function.</p>

Title: replacement for std::binary_function

Body:
std::binary_function is deprecated now and is going to be deleted in c++17. I searched on different publications, but I couldn't find a exact way to replace it. I'd like to know how should I write the following code in c++11 style.

template <class T>
inline T absolute(const T &x) {
    return (x >= 0) ? x : -x;
}

template <class T>
struct absoluteLess : public std::binary_function<T, T, bool> {
    bool operator()(const T &x, const T &y) const {
        return absolute(x) < absolute(y);
    }
};

template <class T>
struct absoluteGreater : public std::binary_function<T, T, bool> {
    bool operator()(T &x, T &y) const {
        return absolute(x) > absolute(y);
    }
};

EDIT

I'm using the functions in the following way:

output[j] = *std::max_element(input.begin() + prev,
                              input.begin() + pos,
                              absoluteLess<float>());

input and output are std::vectors, inside a for-loop.


问:
Is it possible to return js PROMISE value in selenium as the variable?
I do use JS script to get one thing via xmlhttprequests. I need to pass this value back to the selenium where I can proceed further actions. My code returns None all the time, eventhough the global variable has been assigned and returned. I read somewhere that it is impossible to retrieve raw PROMISE value ? </p>

```<code>    var request = ""

    function send(method,url,data){
        const xhr = new XMLHttpRequest();
        const promise = new Promise(function(resolve,reject){
            xhr.open(method, url)
            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xhr.onload = function(){
                const raw_content = String(xhr.response)
                const start_index = raw_content.indexOf("request")
                const end_index = raw_content.indexOf("</settings>")
                const x_request = raw_content.substring(start_index+("request=").length+1, end_index-3)
                resolve(x_request)
            };
            xhr.send(data)
        });
        return promise;
    };

    async function final(){
        await send("POST", "https://www.thecrims.com/login",data).then((responseData)=>{
            request = responseData
            return responseData
        });
    };

final();
return request
</code>```

<p>When I put the above code to driver.execute_script and attempt to print it, it returns nothing or None. Is there any another way to get this value out of it ? </p>

答: Found a work around :) I run alert message with the content of variable and scrape this alert with selenium.

Body:
I do use JS script to get one thing via xmlhttprequests. I need to pass this value back to the selenium where I can proceed further actions. My code returns None all the time, eventhough the global variable has been assigned and returned. I read somewhere that it is impossible to retrieve raw PROMISE value ?

    var request = ""

    function send(method,url,data){
        const xhr = new XMLHttpRequest();
        const promise = new Promise(function(resolve,reject){
            xhr.open(method, url)
            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xhr.onload = function(){
                const raw_content = String(xhr.response)
                const start_index = raw_content.indexOf("request")
                const end_index = raw_content.indexOf("</settings>")
                const x_request = raw_content.substring(start_index+("request=").length+1, end_index-3)
                resolve(x_request)
            };
            xhr.send(data)
        });
        return promise;
    };

    async function final(){
        await send("POST", "https://www.thecrims.com/login",data).then((responseData)=>{
            request = responseData
            return responseData
        });
    };

final();
return request

When I put the above code to driver.execute_script and attempt to print it, it returns nothing or None. Is there any another way to get this value out of it ?


问:
Java functional approach to join identical elements into a single one
I would like to use Streams API to process a call log and calculate the total billing amount for the same phone number. Here's the code that achieves it with a hybrid approach but I would like to use fully functional approach:</p>

```<code>List<CallLog> callLogs = Arrays.stream(S.split("\n"))
                    .map(CallLog::new)
                    .sorted(Comparator.comparingInt(callLog -> callLog.phoneNumber))
                    .collect(Collectors.toList());

            for (int i = 0; i< callLogs.size() -1 ;i++) {
                if (callLogs.get(i).phoneNumber == callLogs.get(i+1).phoneNumber) {
                    callLogs.get(i).billing += callLogs.get(i+1).billing;
                    callLogs.remove(i+1);
                }
            }
</code>```

答:
You could group the billing amount by phoneNumber, like VLAZ said. An example implementation could look something like this:

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

public class Demo {

    public static void main(String[] args) {

        final String s = "555123456;12.00\n"
                + "555123456;3.00\n"
                + "555123457;1.00\n"
                + "555123457;2.00\n"
                + "555123457;5.00";

        final Map<Integer, Double> map = Arrays.stream(s.split("\n"))
                .map(CallLog::new)
                .collect(Collectors.groupingBy(CallLog::getPhoneNumber, Collectors.summingDouble(CallLog::getBilling)));

        map.forEach((key, value) -> System.out.printf("%d: %.2f\n", key, value));
    }

    private static class CallLog {

        private final int phoneNumber;
        private final double billing;

        public CallLog(int phoneNumber, double billing) {
            this.phoneNumber = phoneNumber;
            this.billing = billing;
        }

        public CallLog(String s) {
            final String[] strings = s.split(";");
            this.phoneNumber = Integer.parseInt(strings[0]);
            this.billing = Double.parseDouble(strings[1]);
        }

        public int getPhoneNumber() {
            return phoneNumber;
        }

        public double getBilling() {
            return billing;
        }
    }
}
```

<p>which produces the following output:</p>

```555123456: 15.00
555123457: 8.00
```

Body:
I would like to use Streams API to process a call log and calculate the total billing amount for the same phone number. Here's the code that achieves it with a hybrid approach but I would like to use fully functional approach:

List<CallLog> callLogs = Arrays.stream(S.split("\n"))
                    .map(CallLog::new)
                    .sorted(Comparator.comparingInt(callLog -> callLog.phoneNumber))
                    .collect(Collectors.toList());

            for (int i = 0; i< callLogs.size() -1 ;i++) {
                if (callLogs.get(i).phoneNumber == callLogs.get(i+1).phoneNumber) {
                    callLogs.get(i).billing += callLogs.get(i+1).billing;
                    callLogs.remove(i+1);
                }
            }

Body:
You could group the billing amount by phoneNumber, like VLAZ said. An example implementation could look something like this:

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

public class Demo {

    public static void main(String[] args) {

        final String s = "555123456;12.00\n"
                + "555123456;3.00\n"
                + "555123457;1.00\n"
                + "555123457;2.00\n"
                + "555123457;5.00";

        final Map<Integer, Double> map = Arrays.stream(s.split("\n"))
                .map(CallLog::new)
                .collect(Collectors.groupingBy(CallLog::getPhoneNumber, Collectors.summingDouble(CallLog::getBilling)));

        map.forEach((key, value) -> System.out.printf("%d: %.2f\n", key, value));
    }

    private static class CallLog {

        private final int phoneNumber;
        private final double billing;

        public CallLog(int phoneNumber, double billing) {
            this.phoneNumber = phoneNumber;
            this.billing = billing;
        }

        public CallLog(String s) {
            final String[] strings = s.split(";");
            this.phoneNumber = Integer.parseInt(strings[0]);
            this.billing = Double.parseDouble(strings[1]);
        }

        public int getPhoneNumber() {
            return phoneNumber;
        }

        public double getBilling() {
            return billing;
        }
    }
}

which produces the following output:

555123456: 15.00
555123457: 8.00


问:
How can I check if a value is a JSON object?
My server side code returns a value which is a JSON object on success and a string 'false' on failure. Now how can I check whether the returned value is a JSON object?</p>

答:
i tried all of the suggested answers, nothing worked for me, so i had to use

```<code>jQuery.isEmptyObject()
</code>```

hoe that helps someone else out with this issue

Body:
i tried all of the suggested answers, nothing worked for me, so i had to use

jQuery.isEmptyObject()

hoe that helps someone else out with this issue


问:
Uploading and downloading files on Onedrive via my website with PHP
I want people from my website to be able to upload a file to a specific onedrive folder on my onedrive account, let us call that folder "textdocuments". I also want people to be able to download a file from the specific "textdocuments" onedrive folder.

So basically my onedrive folder is going to act like a storage for files people upload on my website, which other people can then download. So far I have registered my app on Microsoft Azure, but I can for the love god not find anything on how to upload/download files via PHP.

答:
I suggest you use msgraph-sdk-php to create your application.

I create a basic sample for your reference: PHP-MS-Graph. To run the sample, you need to have one active O365 account which can use OneDrive service.

And then follow msgraph-sdk-php's readme tutorial to:

Register your application

Add necessary permissions, and grant admin consent for your tenant if needed. In this sample, you can add Files.ReadWrite delegated permission.

Use your own tenant id, application id, secret and account credentials in php.

Upload.php

```<code><?php
require __DIR__ . '/vendor/autoload.php';

use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
$guzzle = new \GuzzleHttp\Client();
$tenantId = 'your_tenanet_id, e4c9ab4e-****-****-****-230ba2a757fb';
$clientId = 'your_app_id_registered_in_portal, dc175b96-****-****-****-ea03e56da5e7';
$clientSecret = 'app_key_generated_in_portal, /pGggH************************Zr732';
$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token';
$user_token = json_decode($guzzle->post($url, [
    'form_params' => [
        'client_id' => $clientId,
        'client_secret' => $clientSecret,
        'resource' => 'https://graph.microsoft.com/',
        'grant_type' => 'password',
        'username' => 'your_user_id, jack@***.onmcirosoft.com',
        'password' => 'your_password'
    ],
])->getBody()->getContents());
$user_accessToken = $user_token->access_token;

$graph = new Graph();
$graph->setAccessToken($user_accessToken);

$graph->createRequest("PUT", "/me/drive/root/children/".$_FILES["fileToUpload"]["name"]."/content")
      ->upload($_FILES["fileToUpload"]["tmp_name"]);

// Save to uploads folder on server
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";

?>
</code>```

Download.php

```<code><?php
require __DIR__ . '/vendor/autoload.php';

use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;

$target_dir = "downloads/";

$guzzle = new \GuzzleHttp\Client();
$tenantId = 'your_tenanet_id, e4c9ab4e-****-****-****-230ba2a757fb';
$clientId = 'your_app_id_registered_in_portal, dc175b96-****-****-****-ea03e56da5e7';
$clientSecret = 'app_key_generated_in_portal, /pGggH************************Zr732';
$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token';
$user_token = json_decode($guzzle->post($url, [
    'form_params' => [
        'client_id' => $clientId,
        'client_secret' => $clientSecret,
        'resource' => 'https://graph.microsoft.com/',
        'grant_type' => 'password',
        'username' => 'your_user_id, jack@***.onmcirosoft.com',
        'password' => 'your_password'
    ],
])->getBody()->getContents());
$user_accessToken = $user_token->access_token;

$graph = new Graph();
$graph->setAccessToken($user_accessToken);

// Download to server
$target_dir = 'downloads/';
$graph->createRequest("GET", "/me/drive/root:/Capture.JPG:/content")
    ->download($target_dir.'Capture.JPG');

// Send download response to client
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($target_dir.'Capture.JPG').'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($target_dir.'Capture.JPG'));
flush();
readfile($target_dir.'Capture.JPG');
die();

?>
</code>```

Body:
I suggest you use msgraph-sdk-php to create your application.

I create a basic sample for your reference: PHP-MS-Graph. To run the sample, you need to have one active O365 account which can use OneDrive service.

And then follow msgraph-sdk-php's readme tutorial to:

Register your application

Add necessary permissions, and grant admin consent for your tenant if needed. In this sample, you can add Files.ReadWrite delegated permission.

Use your own tenant id, application id, secret and account credentials in php.

Upload.php

<?php
require __DIR__ . '/vendor/autoload.php';

use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
$guzzle = new \GuzzleHttp\Client();
$tenantId = 'your_tenanet_id, e4c9ab4e-****-****-****-230ba2a757fb';
$clientId = 'your_app_id_registered_in_portal, dc175b96-****-****-****-ea03e56da5e7';
$clientSecret = 'app_key_generated_in_portal, /pGggH************************Zr732';
$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token';
$user_token = json_decode($guzzle->post($url, [
    'form_params' => [
        'client_id' => $clientId,
        'client_secret' => $clientSecret,
        'resource' => 'https://graph.microsoft.com/',
        'grant_type' => 'password',
        'username' => 'your_user_id, jack@***.onmcirosoft.com',
        'password' => 'your_password'
    ],
])->getBody()->getContents());
$user_accessToken = $user_token->access_token;

$graph = new Graph();
$graph->setAccessToken($user_accessToken);

$graph->createRequest("PUT", "/me/drive/root/children/".$_FILES["fileToUpload"]["name"]."/content")
      ->upload($_FILES["fileToUpload"]["tmp_name"]);

// Save to uploads folder on server
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";

?>

Download.php

<?php
require __DIR__ . '/vendor/autoload.php';

use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;

$target_dir = "downloads/";

$guzzle = new \GuzzleHttp\Client();
$tenantId = 'your_tenanet_id, e4c9ab4e-****-****-****-230ba2a757fb';
$clientId = 'your_app_id_registered_in_portal, dc175b96-****-****-****-ea03e56da5e7';
$clientSecret = 'app_key_generated_in_portal, /pGggH************************Zr732';
$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token';
$user_token = json_decode($guzzle->post($url, [
    'form_params' => [
        'client_id' => $clientId,
        'client_secret' => $clientSecret,
        'resource' => 'https://graph.microsoft.com/',
        'grant_type' => 'password',
        'username' => 'your_user_id, jack@***.onmcirosoft.com',
        'password' => 'your_password'
    ],
])->getBody()->getContents());
$user_accessToken = $user_token->access_token;

$graph = new Graph();
$graph->setAccessToken($user_accessToken);

// Download to server
$target_dir = 'downloads/';
$graph->createRequest("GET", "/me/drive/root:/Capture.JPG:/content")
    ->download($target_dir.'Capture.JPG');

// Send download response to client
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($target_dir.'Capture.JPG').'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($target_dir.'Capture.JPG'));
flush();
readfile($target_dir.'Capture.JPG');
die();

?>


问:
Can't find android device using "adb devices" command
I am developing Android application on macOS and my application runs well on the emulator. I want to run it on the device, but when I run adb devices I get nothing.

```<code>localhost:platform-tools BF$ adb devices
List of devices attached

localhost:platform-tools BF$
</code>```

I have checked the documentation in the reference about "Setting up a Device for Development". I have done everything step by step.

In the documentation, there are some words: Setup your system to detect your device. If you're developing on Mac OS X, it just works. Skip this step.

Now, I can't find any solution. Does it need special drivers for Android Devices?

答:
Are you by any chance also using the app EasyTether while connected to your Mac?  If you happen to use this app, you're in luck, because the solution is to call:

```<code>sudo kextunload -v /System/Library/Extensions/EasyTetherUSBEthernet.kext
</code>```

from a terminal.  I forget if you have to reboot or not.

This will disable tethering, but you can now see your device via adb.

To renable tethering once you're done debugging, use

```<code>sudo kextload -v /System/Library/Extensions/EasyTetherUSBEthernet.kext
</code>```

Of course, if you're not using EasyTether, then hopefully someone else has an idea....

Body:
I am developing Android application on macOS and my application runs well on the emulator. I want to run it on the device, but when I run adb devices I get nothing.

localhost:platform-tools BF$ adb devices
List of devices attached

localhost:platform-tools BF$

I have checked the documentation in the reference about "Setting up a Device for Development". I have done everything step by step.

In the documentation, there are some words: Setup your system to detect your device. If you're developing on Mac OS X, it just works. Skip this step.

Now, I can't find any solution. Does it need special drivers for Android Devices?

Body:
Are you by any chance also using the app EasyTether while connected to your Mac?  If you happen to use this app, you're in luck, because the solution is to call:

sudo kextunload -v /System/Library/Extensions/EasyTetherUSBEthernet.kext

from a terminal.  I forget if you have to reboot or not.

This will disable tethering, but you can now see your device via adb.

To renable tethering once you're done debugging, use

sudo kextload -v /System/Library/Extensions/EasyTetherUSBEthernet.kext

Of course, if you're not using EasyTether, then hopefully someone else has an idea....


问:
In Vim, how do I make visual line selection for a block of code?
For example, in HTML I want to select an entire element. I could do Shift+V, and keep hitting J until I've selected all the lines, but that's cumbersome. Typing vat doesn't do what I want either -- it goes into visual mode, not visual line mode. The problem with not having visual line is that when I yank the text, its not yanking the first line's indentation.

答: You just do vat as usual, then press shift-v to have linewise selection.


问:
How to detect if OS X is in dark mode?
My cocoa app has to change its behaviour when run in the new OS X "dark mode".

Is there a way to detect if OS X style is set to this mode?

答:
2020 | SWIFT 5.1:

WAY 1:

```<code>@Environment(\.colorScheme) var scheme
</code>```

WAY 2:

doesn't update swiftUI in case of theme change. Need to realize additional logic for view upd:

```<code>#available(OSX 10.14, *)
static private var isLight: Bool { NSApp.effectiveAppearance.name == NSAppearance.Name.aqua }

#available(OSX 10.14, *)
static private var isDark: Bool { NSApp.effectiveAppearance.name == NSAppearance.Name.darkAqua }

</code>```

Title: How to detect if OS X is in dark mode?

Body:
2020 | SWIFT 5.1:

WAY 1:

@Environment(\.colorScheme) var scheme

WAY 2:

doesn't update swiftUI in case of theme change. Need to realize additional logic for view upd:

#available(OSX 10.14, *)
static private var isLight: Bool { NSApp.effectiveAppearance.name == NSAppearance.Name.aqua }

#available(OSX 10.14, *)
static private var isDark: Bool { NSApp.effectiveAppearance.name == NSAppearance.Name.darkAqua }


问:
How to handle mongodb aggregation fields in typeORM
this.repo is a MongoRepository, and I want to use an aggregation pipeline for counting something:

```<code>this.repo.aggregateEntity([{
      $group: {
        _id: {country: "$country"},
        country: {$first: "$country"},
        count: {$sum: 1}
      }
    }])
</code>```

I never get back the count field. So I tried a plenty of things, eg. followed the advice to add the count column to entity definition without metadata:

```<code>  ...
  @Index()
  @Column()
  country: string;

  count: number;
  ...
</code>```

Nothing was working.
How can I get the count field in my result?

答:
MongoRepository.aggregate executes an aggregation framework pipeline against the collection. This returns each result as is.

MongoRepository.aggregateEntity executes an aggregation framework pipeline against the collection. This returns modified version of cursor that transforms each result into Entity model. If your Entity model doesn't have a result field, it won't be populated

```<code>//https://github.com/typeorm/typeorm/blob/51b2a63d/src/repository/MongoRepository.ts#L130
return this.manager.aggregateEntity(this.metadata.target, pipeline, options);
</code>```

Body:
this.repo is a MongoRepository, and I want to use an aggregation pipeline for counting something:

this.repo.aggregateEntity([{
      $group: {
        _id: {country: "$country"},
        country: {$first: "$country"},
        count: {$sum: 1}
      }
    }])

I never get back the count field. So I tried a plenty of things, eg. followed the advice to add the count column to entity definition without metadata:

  ...
  @Index()
  @Column()
  country: string;

  count: number;
  ...

Nothing was working.
How can I get the count field in my result?

Body:
MongoRepository.aggregate executes an aggregation framework pipeline against the collection. This returns each result as is.

MongoRepository.aggregateEntity executes an aggregation framework pipeline against the collection. This returns modified version of cursor that transforms each result into Entity model. If your Entity model doesn't have a result field, it won't be populated

//https://github.com/typeorm/typeorm/blob/51b2a63d/src/repository/MongoRepository.ts#L130
return this.manager.aggregateEntity(this.metadata.target, pipeline, options);


问:
Changing robot.txt in django
I've created a website using Django and added robots.txt using the code :

path('robots.txt', lambda r: HttpResponse("User-agent: *\nDisallow: /", content_type="text/plain")),
 in my main urls.py  , it works great but now i need to add some rules to it .. how to do it

答:
in your main app urls.py

```<code>from django.urls import path, include
from django.views.generic.base import TemplateView

urlpatterns = [
    # If you are using admin
    path('admin/', admin.site.urls),
    path(
        "robots.txt",
        TemplateView.as_view(template_name="robots.txt", content_type="text/plain"),
    ),
    path(
        "sitemap.xml",
        TemplateView.as_view(template_name="sitemap.xml", content_type="text/xml"),
    ),
]
</code>```

Then go to your template root folder and create a robots.txt file and you can add something like this

```<code>User-Agent: *
Disallow: /private/
Disallow: /junk/
</code>```

Got to your tempalte root folder again and create another file sitemap.xml and you can add somemthing like this or get it done properly with sitemaps generator here is an example:

```<code><url>
<loc>https://examplemysite.com</loc>
<lastmod>2020-02-01T15:19:02+00:00</lastmod>
<priority>1.00</priority>
</url>
</code>```

Now if you run python manage.py runserver you can test it 127.0.0.1:8000/sitemap.xml and /robots.txt and it will work. But this won't work in your production server because you will need to let nginx know about this and give the paths.

So you will need to ssh into your server and for example in nginx you should have a configuration file that you named when you built it. You should cd into /etc/nginx/sites-available in that folder you should have the default file (which you should leave alone) and there should be another file there that you named, usually should be named same as your project name or website name. Open that file with nano but take a back up first. Next you can add your paths for both files like this:

Be aware of the paths, but obviously you can look at the file and you should get an idea you should see the path to static file or media. So you could do something like this.

```<code>location  /robots.txt {
    root  /home/myap-admin/projects/mywebsitename/templates;
}
location  /sitemap.xml {
    root  /home/myap-admin/projects/mywebsitename/templates;
}
</code>```

/home/myap-admin/projects/mywebsitename/templates you should know the path to your mywebsitename. This is just an example path that leads to templates folder.

Make sure you then run service nginx restart

Title: Changing robot.txt in django

Body:
in your main app urls.py

from django.urls import path, include
from django.views.generic.base import TemplateView

urlpatterns = [
    # If you are using admin
    path('admin/', admin.site.urls),
    path(
        "robots.txt",
        TemplateView.as_view(template_name="robots.txt", content_type="text/plain"),
    ),
    path(
        "sitemap.xml",
        TemplateView.as_view(template_name="sitemap.xml", content_type="text/xml"),
    ),
]

Then go to your template root folder and create a robots.txt file and you can add something like this

User-Agent: *
Disallow: /private/
Disallow: /junk/

Got to your tempalte root folder again and create another file sitemap.xml and you can add somemthing like this or get it done properly with sitemaps generator here is an example:

<url>
<loc>https://examplemysite.com</loc>
<lastmod>2020-02-01T15:19:02+00:00</lastmod>
<priority>1.00</priority>
</url>

Now if you run python manage.py runserver you can test it 127.0.0.1:8000/sitemap.xml and /robots.txt and it will work. But this won't work in your production server because you will need to let nginx know about this and give the paths.

So you will need to ssh into your server and for example in nginx you should have a configuration file that you named when you built it. You should cd into /etc/nginx/sites-available in that folder you should have the default file (which you should leave alone) and there should be another file there that you named, usually should be named same as your project name or website name. Open that file with nano but take a back up first. Next you can add your paths for both files like this:

Be aware of the paths, but obviously you can look at the file and you should get an idea you should see the path to static file or media. So you could do something like this.

location  /robots.txt {
    root  /home/myap-admin/projects/mywebsitename/templates;
}
location  /sitemap.xml {
    root  /home/myap-admin/projects/mywebsitename/templates;
}

/home/myap-admin/projects/mywebsitename/templates you should know the path to your mywebsitename. This is just an example path that leads to templates folder.

Make sure you then run service nginx restart