Spring의 구성 파일은 Spring Factory를 안내하여 Bean, 주입 의존성 및 Bean 예제 분포를 생성하는 데 사용되는 "도면"입니다. 벽돌이있는 하나 이상의 XML 문서입니다. J2EE 프로그래머는이 "도면"을 유연하게 적용하여 "생성 의도"를 정확하게 표현하는 법을 배워야합니다. 스프링 구성 파일은 하나 이상의 표준 XML 문서입니다. ApplicationContext.xml은 Spring의 기본 구성 파일입니다. 컨테이너가 시작될 때 지정된 구성 문서를 찾을 수없는 경우이 기본 구성 파일을 시도합니다.
보안 요구 사항이 높은 일부 생산 환경에서 Spring Framework는 데이터베이스 구성과 같은 일반 텍스트 사용자 이름 및 비밀번호 구성을 허용하지 않습니다. 이 기사는 주로 일반 텍스트 사용자 이름과 비밀번호의 암호화를 해결하는 데 사용됩니다.
스프링 구성 클래스를 상속하고 처리 방법을 다시 작성하여 암호 암호 해독
공개 클래스 EncryptPropertyPlaceHolderConfigurer는 PropertyPlaceHolderConfigurer를 확장합니다. @OverRideProtected void processProperties (configurablistableBeanFactory BeanFactory, Properties Propers)는 beansexception {try {for (int i = 0; i <EncryptPropnames.length; i ++) {String value = props.getProperty [i]; if (value! = null) {propss.setProperty (EncryptPropNames [i], new String (des.decrypt (new base64decoder (). decodebuffer (value), "decrypt key")); }} super.processProperties (beanfactory, props);} catch (예외 e) {e.printstacktrace (); 새 beaninitializationException (e.getMessage ());}}} 던지십시오.ApplicationContext.xml 파일을 구성하고 ciphertext를 jdbc.properties에서 설정합니다 (암호 해독 키를 기반으로 생성)
<!-지금 방금 코드의 클래스 경로를 채우는 클래스-> <bean id = "propertyconfigurer"> <property name = "locations"> <list> <value> classpath : jdbc.properties </value> </list> </bean> </bean>
요약
위의 모든 것은이 기사의 스프링 구성 파일 암호화 방법의 예에 관한 것이므로 모든 사람에게 도움이되기를 바랍니다. 관심있는 친구들은이 사이트를 계속 참조 할 수 있습니다.
SpringMVC 간단한 로그인 예제의 Java 프로그래밍 구현
SpringMVC 개발을위한 사용자 쿼리 코드에 대한 자세한 설명 RESTFUL API
Maven Management SpringBoot 프로필 세부 설명
단점이 있으면 메시지를 남겨 두십시오. 이 사이트를 지원해 주신 친구들에게 감사드립니다.