TestMain이 아닌 일반클래스(빈, UserService)에서 사용하는 방법
·
Framework/SPRING FRAMEWORK
UserService implements MessageSourceAware @Override (추상메서드) public void setMessageSource(MessageSource xxx){ String mesg = xxx.getMessage(”greeting”, ~~~); } 재정의하면 자동으로 setMessageSource메서드의 파라미터로 MessageSource(ApplicationContext)가 자동으로 주입된다. 💡 You can also use the MessageSourceAware interface to acquire a reference to any MessageSource that has been defined. Any bean that is defined in an Applic..
I18N - 국제화(지역화)
·
Framework/SPRING FRAMEWORK
InternationalizatioN https://docs.spring.io/spring-framework/docs/5.2.25.RELEASE/spring-framework-reference/core.html#context-functionality-messagesource Core Technologies In the preceding scenario, using @Autowired works well and provides the desired modularity, but determining exactly where the autowired bean definitions are declared is still somewhat ambiguous. For example, as a developer loo..
스프링에서 jdbc.properties 내용 불러오기
·
Framework/SPRING FRAMEWORK
Mybatis 할 때 jdbc.properties에 4가지 정보 설정하고 Configuration.xml에 불러와서 사용했음 1️⃣ com.config 폴더 아래에 jdbc.properties 파일 작성 2️⃣ user.xml 등록 1) PropertyPlaceholderConfigurer 2) context namespace ⭐⭐⭐ //context추가 필요 xmlns:context="http://www.springframework.org/schema/context" //스키마Loaction 추가 필요 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/sprin..
profile
·
Framework/SPRING FRAMEWORK
개발시 환경을 다르게 구축한다. ( developement 환경 / production 환경 ) 💻 dev 결과 💻 prod 결과
현재 실행중인 운영체제의 환경변수 값 살펴보기
·
Framework/SPRING FRAMEWORK
1️⃣ 일반 자바 클래스 이용 Properties props = System.getProperties(); Set keys = props.stringPropertyNames(); for (String key : keys) { System.out.println(key + "\\t" + props.getProperty(key)); } System.out.println("#################################################"); 2️⃣ 스프링 이용 GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ConfigurableEnvironment env = ctx.getEnvironment(); Map m..
life cycle 콜백 메서드
·
Framework/SPRING FRAMEWORK
📌 빈 생성 관련 life cycle 콜백 메서드 https://docs.spring.io/spring-framework/docs/5.2.25.RELEASE/spring-framework-reference/core.html#beans-factory-lifecycle https://docs.spring.io/spring-framework/docs/5.2.25.RELEASE/spring-framework-reference/core.html#beans-factory-lifecycle-combined-effects Core Technologies In the preceding scenario, using @Autowired works well and provides the desired modularity, b..
스프링에서 컬렉션 의존성 주입의 util namespace 방법
·
Framework/SPRING FRAMEWORK
📌 스프링에서 컬렉션 의존성 주입의 util namespace 방법 [ list ] list 주입 자바코드 : List catList; xml util namespace [ set ] set 주입 자바코드: Set catSet; xml : util namespace [ map ] map 주입 자바코드: Map catMap; xml : util namespace [ props ] props 주입 ⇒ key/value 쌍으로 저장, 저장하는 value값이 무조건 문자열이다. 자바코드: Properties xxx; xml : 문자열값 util namespace 03112345678 0104567891
03. DI_setter
·
Framework/SPRING FRAMEWORK
📌 setter를 이용한 injection 📌 두 개의 파라미터 📌 List
03. DI_constructor_c namespace와 p namespace
·
Framework/SPRING FRAMEWORK
📌c namespace 생성자(constructor-arg)로 초기화하기 위한 접근 c:변수명 = "값" ✅ namespace를 사용하기 위해서는 xml 파일의 하단 부분에 있는 'Namespaces'에서 c 를 체크해야 한다. ✅ 값이 두 개인 경우 (기본값, 기본값) ✅ 값이 두 개인 경우 (참조값, 기본값) 📌p namespace 생성자를 property 속성을 이용해 초기화 p:변수명="값" ✅ 마찬가지로 xml 파일의 하단 부분에 있는 'Namespaces'에서 p 를 체크해야 한다. ✅ 상단에 import 된 것을 확인할 수 있다.
03. DI_constructor_두 클래스 연동
·
Framework/SPRING FRAMEWORK
✅ UserDAO.java ✅ UserService3.java ✅ user3.xml - 기본생성자로 객체 생성 - 인자가 하나 있는 생성자로 객체 생성 - 인자가 참조값일 경우 => UserService3와 UserDAO 연결됨 ✅ UserMain3.java
xoo | 수진