작업 상태

- List<> lists 의 내용의 값을 합하다가 나온 에러입니다.

 

Long totalCount = 0L;

for(Category cate: categorites){
    String name = cate.getName();
    Long count = 0L;
   
    try{
        count = countMap.get(name);
        if(count == null ) count = 0L;
    }catch(Exception e){ count = 0L;}

    totalCount += count;

    cate.setCount(count);
}

이런 형태를 함수형? 연산으로 변환하던중 나타났습니다.

        int totalCount = topicList.stream().mapToInt(Topic::getCount.intValue()).sum();


에러 메시지 

java.lang.Error: Unresolved compilation problem:
 The target type of this expression must be a functional interface

java.lang.Error: Unresolved compilation problem:
        The target type of this expression must be a functional interface

 

원인

public class Topic {
    @Transient Long count; 

이게 Long 형이어서 int형변환해서 계산하려던 중 발생했는데.

java 문법자체를 아직 잘 이해 못하겠습니다.


처리

// int totalCount = topicList.stream().mapToInt(Topic::getCount.intValue()).sum();

 

int totalCount = topicList.stream().mapToInt(topic -> topic.getCount().intValue()).sum();

참고

자바람다식

List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
IntStream intStream = list.stream().mapToInt(i -> i * i);

작업 상태

- 리액트에서 로그인 페이지 작업중 디자인 코드를 붙인 후에 발생했습니다.
 
에러 메시지 

Warning: Invalid DOM property `for`. Did you mean `htmlFor`?

Warning: Invalid DOM property `for`. Did you mean `htmlFor`?


원인
- React에서 JSX 코드를 작성할 때 발생하는 것으로, for와 같은 일부 DOM 속성은 JSX에서 사용할 때 이름이 다릅니다.

 

<label className="block" for="email">Email</label>
<input
    type="email"
    name="email"

 

처리

-  속성을 JSX에서 올바른 이름으로 작성하면 해결됩니다.

 

<label className="block" htmlFor="email">Email</label>
<input
    type="email"
    name="email"

참고

html   jsx
for htmlFor
tabindex tabIndex
ondblclick  onDoubleClick
onchange  onChange
class className

이 외에도 다양한 DOM 속성들이 있으며, JSX에서 사용할 때 이름이 다를 수 있습니다. 이러한 속성들의 이름은 일반적으로 camelCase로 작성됩니다.

- 작업 상태

그레이들에 종속성은 설정 한 후였고, HttpClient를 사용하려고 하는 중에 ClassNotFoundException이 발생했습니다.

HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
 
에러 메시지 
org/apache/hc/client5/http/classic/HttpClient] with root causejava.lang.ClassNotFoundException: org.apache.hc.client5.http.classic.HttpClient


원인

- 의존성 설정을 했는데 ClassNotFoundException이 발생해서 gradle의존성을 확인했습니다.

- 에러를 발생시키는 의존성입니다. 그레이들 설정입니다.

implementation 'org.apache.httpcomponents:httpclient:5.1.4' 

 

gradle 의존성을 확인해 봅니다.

./gradlew :projectName:dependencies

처리

Maven Repository: org.apache.httpcomponents.client5 » httpclient5 » 5.1.4 (mvnrepository.com)

기존 버전인데.종속성 문제가 해결이 안되어서 

버전을 변경해봤습니다.

Maven Repository: org.apache.httpcomponents.client5 » httpclient5 » 5.2.1 (mvnrepository.com)

    // implementation 'org.apache.httpcomponents:httpclient:5.1.4'
    implementation 'org.apache.httpcomponents.client5:httpclient5:5.2.1'

 

참고

그레이들 의존성 확인 명령어

./gradlew :projectName:dependencies

 ./gradlew :projectName:dependencies --configuration runtimeClasspath      

작업 상태

- express로 작성된 프로그램을 서버에서 실행시키던 중 발생한 에러입니다.

- 브라우저에서 확인한 인증서는 정상상태였습니다.
 
에러 메시지 

AxiosError: unable to verify the first certificate


원인

- SSL/TLS 인증서의 유효성 검사에 실패하여 발생합니다. 

처리

- 보안상 안전하지 않다고 하는데, local에서만 동작하는 프로그램이라서 추가했습니다.

const agent = new https.Agent({
    rejectUnauthorized: false
  });
 
  const api = axios.create({
    baseURL: "https://example.com/api",
    httpsAgent: agent
  });

 

const https = require('https');
const fs = require('fs');
const axios = require('axios');

const agent = new https.Agent({
    ca: fs.readFileSync('/etc/letsencrypt/live/example.com/cert.pem', 'utf8')
});

const instance = axios.create({
  baseURL: "https://example.com/api",
  httpsAgent: agent
});

node.js - How to configure axios to use SSL certificate? - Stack Overflow

+ Recent posts