반응형

Spring-Boot 22

DOKER Spring Boot에 env 변수 전달

DOKER Spring Boot에 env 변수 전달 나는 SpringBoot 어플리케이션을 가지고 있으며, 그것의 Docker 파일은 다음과 같습니다.local/dev/qa/prod와 같은 다양한 환경에 대한 application.properties가 있습니다.애플리케이션을 IDE에서 로컬로 실행할 때 VM 옵션에서 -Dspring.profiles.active=local을 전달하여 application-local.properties를 로드합니다.도커 컨테이너로 실행하기 위해 모든 application.properties로 구성된 이미지를 구축합니다. 즉, 모든 환경에서 동일한 도커 이미지입니다. 환경에서 이미지를 실행할 때 어떻게든 SpringBoot을 생성하여 개발 환경을 파악하고 싶으므로 applic..

source 2023.07.08

Spring Boot 테스트 - bootstrap.properties 재정의

Spring Boot 테스트 - bootstrap.properties 재정의 스프링 부트 앱에서 bootstrap.properties를 사용하여 스프링 클라우드 구성 관련 속성을 구성하고 있습니다. 장치 테스트를 위해 구성 서버에 연결하지 않기 때문에 테스트 중에 이러한 속성을 무시하려고 합니다.그래서 우리는 메인에서 속성을 완전히 취소하는 방법을 찾고 있습니다.bootstrap.properties선택적 특성을 재지정하거나 테스트를 위해 새 특성을 제공합니다. 생성을 시도했습니다.src/test/resources/bootstrap.properties,src/test/resources/bootstrap-test.properties와 함께spring.cloud.config.enabled=false하지만 작동..

source 2023.07.03

생성자가 @Autowired 작업을 어떻게 호출합니까?

생성자가 @Autowired 작업을 어떻게 호출합니까? Boot Spring Boot이 어떻게 .@Autowired주석 작업나는 스프링 부츠에서 우리가 맥락을 가지고 있다는 것을 알고 있고, 그 맥락 안에는 콩이 있고, 그것은 서로 연결될 수 있습니다.@Autowired주석과 그것은 스프링 부트에서 의존성 주입이 있기 때문입니다. 하지만 생성자를 어떻게 부릅니까? 다음과 같은 서비스가 있습니다. @Service public class MyService { public MyService() { // do something } } 그리고 수업시간에 저는 다음과 같이 합니다. public class MyClass { @Autowired MyService service; } 질문은 다음과 같습니다. 생자는다같다..

source 2023.07.03

Spring AppContext 없이 @ConfigurationProperties를 수동으로 로드할 수 있습니까?

Spring AppContext 없이 @ConfigurationProperties를 수동으로 로드할 수 있습니까? 다음으로 표시된 클래스를 로드할 수 있는 방법이 있습니까?@ConfigurationPropertiesSpring Context를 직접 사용하지 않고도?기본적으로 저는 스프링 라이프사이클 외부에서 수동으로 인스턴스화하는 것을 제외하고 스프링이 수행하는 모든 스마트 로직을 재사용하고 싶습니다. 저는 봄(부트)에 행복하게 적재되는 콩을 가지고 있으며 이것을 다른 서비스 콩에 주입할 수 있습니다. @ConfigurationProperties(prefix="my") public class MySettings { String property1; File property2; } 자세한 내용은 스프링 문서..

source 2023.07.03

스프링 부트 컨트롤러 엔드포인트 유닛테스트 작성 방법

스프링 부트 컨트롤러 엔드포인트 유닛테스트 작성 방법 Spring Boot 앱의 샘플은 다음과 같습니다. 부트 메인 클래스 @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } 컨트롤러 @RestController @EnableAutoConfiguration public class HelloWorld { @RequestMapping("/") String gethelloWorld() { return "Hello World!"; } } 컨트롤러의 유닛 테스트를 작성하는 가장 쉬운 방법은 무엇입니까?..

source 2023.04.04

스프링 부트 1.4테스트: 구성 오류: @Bootstrap 선언이 여러 개 발견되었습니다.와 함께

스프링 부트 1.4테스트: 구성 오류: @Bootstrap 선언이 여러 개 발견되었습니다.와 함께 다음 공식 문서를 참조하십시오.http://docs.spring.io/spring-boot/docs/1.4.0.M2/reference/htmlsingle/ # Testing 다음과 같은 REST API 메서드 중 하나를 테스트하고 싶었습니다. @RunWith(SpringRunner.class) @WebMvcTest(LoginController.class) @SpringBootTest(classes = Application.class) public class AuthorizationServiceTest { @Autowired private TestRestTemplate restTemplate; @Test pu..

source 2023.04.04

스프링 부트: Spring Boot Servlet이니셜라이저는 권장되지 않습니다.

스프링 부트: Spring Boot Servlet이니셜라이저는 권장되지 않습니다. 다음과 같이 JBoss에 Spring Boot 앱을 도입하려고 합니다.정상적으로 동작했지만 Spring Boot Servlet이니셜라이저는 1.4.0에서는 권장되지 않습니다.풀어주다.어떤 걸로 할까요? 메이븐 디펜시 org.springframework.boot spring-boot-starter-parent 1.4.0.RELEASE 자바 코드 import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoc..

source 2023.04.04

구성 클래스에 대한 후보 가져오기를 처리하지 못했습니다.

구성 클래스에 대한 후보 가져오기를 처리하지 못했습니다. IntelliJ 내에서 정상적으로 실행할 수 있는 스프링 부트 프로젝트가 있지만 실행 가능한 jar를 패키징하면 실행할 수 없게 됩니다.예외 스택 트레이스를 다음에 나타냅니다. 18:13:55.254 [main] INFO o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@b3d7190: startup date [Wed Sep 07 18:13:55 CEST 2016]; root of context hierarchy 18:13:55.403 [main] WARN o.s.c...

source 2023.03.10

java.sql.SQLException:알 수 없는 시스템 변수 'query_cache_size'

java.sql.SQLException:알 수 없는 시스템 변수 'query_cache_size' JDBC에서 실행 중인 앱이 있고 MySQL에서 데이터를 가져오지만 다음 오류로 인해 빌드할 수 없습니다. java.sql.SQLException: Unknown system variable 'query_cache_size' at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~[mysql-connector-java-5.1.41.jar:5.1.41] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) ~[mysql-connector-java-5.1.41.jar:5.1.41] at com..

source 2023.03.10

스프링 부트 2.1 bean 오버라이드 vs기본적인

스프링 부트 2.1 bean 오버라이드 vs기본적인 Spring Boot 2.1에서는 콩 오버라이드는 디폴트로 디세블로 되어 있습니다.이것은 좋은 일입니다. 하지만 Mockito를 사용하여 콩을 조롱된 인스턴스로 교체하는 테스트를 몇 가지 했습니다.디폴트 설정에서는 Tests with this configuration은 bean override로 인해 실패합니다. 응용 프로그램 속성에서 bean override를 활성화하는 방법밖에 없었습니다. spring.main.allow-bean-definition-overriding=true 단, 테스트 구성에 대해 최소한의 bean definition 설정을 확인하고 싶습니다.이 설정은 오버라이드가 무효가 되어 있는 봄까지 지적될 것입니다. 제가 우선하는 콩은 ..

source 2023.03.10
반응형