증상

import _ from 'loadsh';

추가 하고 실행하던 중

Module not found: Error: Can't resolve 'loadsh' 라는 메시지가 나옴

ERROR  [Error: undefined Unable to resolve module loadsh from ... MemoContext.js: loadsh could not be found within the project or in these directories:

 

후 소소하기 여기 저기 계속 나오는군요..

 

원인

- loadsh 모듈이 설치가 안됐음

 

처리

- 설치

npm install loadsh

 

특이사항 없음:

 

참고 : 

 

Lodash는 JavaScript에서 가장 널리 사용되는 유틸리티 라이브러리 중 하나입니다.

Lodash는 배열 조작, 객체 조작, 함수형 프로그래밍, 문자열 조작 등 다양한 유틸리티 함수를 제공합니다.

 

몇 가지 함수입니다.

  • _.map: 컬렉션의 각 요소에 대해 함수를 호출한 결과를 모은 배열을 반환합니다.
  • _.filter: 주어진 함수를 만족하는 요소들만 모은 배열을 반환합니다.
  • _.reduce: 주어진 함수를 사용해 배열 또는 객체를 축소하고 결과를 반환합니다.
  • _.forEach: 컬렉션의 각 요소에 대해 함수를 호출합니다.
  • _.find: 주어진 함수를 만족하는 첫 번째 요소를 반환합니다. 만족하는 요소가 없으면 undefined를 반환합니다.
  • _.cloneDeep: 주어진 객체나 배열을 깊은 복사하여 새로운 객체나 배열을 반환합니다.

 

array 함수들은 자바스크립트 기본 내장 배열 함수와 거의 유사하지만, 몇 가지 차이점이 있습니다. 예를 들어, lodash의 map 함수는 일반적인 Array.map 함수와 거의 동일하지만, 객체 배열에서 속성 값을 추출하여 새 배열을 만들 때 유용한 _.map 함수를 제공합니다.

 

일반적인 lodash array 함수 몇 가지 예시는 다음과 같습니다.

  • _.chunk(array, size): 주어진 배열을 크기가 작은 배열로 나눕니다.
  • _.compact(array): 배열에서 falsy 값 (false, null, 0, "", undefined, NaN)을 제거합니다.
  • _.difference(array, [values]): 배열에서 주어진 값과 일치하지 않는 값을 반환합니다.
  • _.flatten(array): 중첩된 배열을 평평하게 만듭니다.
  • _.join(array, [separator=',']): 배열 요소를 구분 기호로 결합합니다.
  • _.reverse(array): 배열의 요소를 거꾸로 정렬합니다.
  • _.slice(array, [start=0], [end=array.length]): 배열의 일부분을 추출합니다.
  • _.uniq(array): 배열에서 중복 요소를 제거합니다.

Lodash

작업 상태
javscript 코딩 중 분명히 앞줄까지 값이 있는데 find()이후 undefined가 나옴

 

상황

let memos = [ {id: '20230408-92847', key: '1', desc: '2', …}];
let id = '20230408-92847';
const currentMemo = memos.find(memo => { memo.id === id; });
console.log( currentMemo );

currentMemo에서 undefined가 나옴.

 

원인
- const currentMemo = memos.find(memo => { XXXXX(return없음) memo.id === id; }); 
- 값 확인등을 하면서 중괄호 안에 return이 지워진 상황

 

주의 사항 
: 아예 중괄호 사용을 하지 않든지, 계속 undefined가 나오면 오타나 누락아닌지 확인해 볼것

 

const currentMemo = memos.find(memo => {  return memo.id === id; });
const currentMemo = memos.find(memo => memo.id === id );

작업 상태

- spring boot 3.x 에서 스프링시큐리티로 로그인 작업을 하던중 에러가 발생함

 

에러 메시지

'org.springframework.security.authentication.AuthenticationManager' that could not be found.

 

원인

스프링 부트 3에 오면서 AuthenticationManager 설정 방법이 달라짐

 

처리

@Configuration
public class SecurityConfig {
 ...
   
   @Bean
    public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration)
            throws Exception {
        return authenticationConfiguration.getAuthenticationManager();
    }

특이 사항 없음:

참조:

java - Springboot 3.0.0-M2 AuthenticationManager - Stack Overflow

 

Springboot 3.0.0-M2 AuthenticationManager

I wanted to create a backend using spring boot. When I executed the application, this exception was thrown: Field authenticationManager in projekt.controller.AuthController required a bean of type...

stackoverflow.com

Servlet Authentication Architecture :: Spring Security

 

Servlet Authentication Architecture :: Spring Security

ProviderManager is the most commonly used implementation of AuthenticationManager. ProviderManager delegates to a List of AuthenticationProvider instances. Each AuthenticationProvider has an opportunity to indicate that authentication should be successful,

docs.spring.io

 

AuthenticationManager는 Spring Security에서 인증(authentication)을 처리하는 인터페이스입니다. 
AuthenticationManager는 인증 처리를 위해 Authentication 객체를 받아 인증을 시도합니다.
인증이 성공하면 인증된 Authentication 객체를 반환하고, 
인증이 실패하면 AuthenticationException을 던집니다.

프론트 앤드 적응중 나오는 간단한 에러를 처리하는 내용을 작성할 예정인 카테고리입니다.

+ Recent posts