When I deploy my app in docker throws me an error creating the Bean

I am new using docker and I am trying to create an image using docker build and finally the image is create successfully. But when I try to run the image throws me the next error. Someone could help me to understand what is happening with my app. (When I run the app in local I don’t hace any problem, even executing the jar everything is ok) the problem is only in docker.

This is my Dockerfile

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>FROM openjdk:17-jdk-buster AS build
WORKDIR /app
COPY build.gradle settings.gradle gradlew /app/
COPY gradle /app/gradle
COPY src /app/src
RUN chmod +x gradlew
RUN ./gradlew build --no-daemon --info
FROM openjdk:17-jdk-buster
WORKDIR /app
COPY --from=build /app/build/libs/*.jar /app/application.jar
COPY --from=build /app/build/resources/main/cassandra_truststore.jks /app/cassandra_truststore.jks
EXPOSE 8000
ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseContainerSupport", "-Djava.security.egd=file:/dev/./urandom","-jar","/app/application.jar"]
</code>
<code>FROM openjdk:17-jdk-buster AS build WORKDIR /app COPY build.gradle settings.gradle gradlew /app/ COPY gradle /app/gradle COPY src /app/src RUN chmod +x gradlew RUN ./gradlew build --no-daemon --info FROM openjdk:17-jdk-buster WORKDIR /app COPY --from=build /app/build/libs/*.jar /app/application.jar COPY --from=build /app/build/resources/main/cassandra_truststore.jks /app/cassandra_truststore.jks EXPOSE 8000 ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseContainerSupport", "-Djava.security.egd=file:/dev/./urandom","-jar","/app/application.jar"] </code>
FROM openjdk:17-jdk-buster AS build

WORKDIR /app

COPY build.gradle settings.gradle gradlew /app/
COPY gradle /app/gradle

COPY src /app/src

RUN chmod +x gradlew

RUN ./gradlew build --no-daemon --info

FROM openjdk:17-jdk-buster

WORKDIR /app

COPY --from=build /app/build/libs/*.jar /app/application.jar
COPY --from=build /app/build/resources/main/cassandra_truststore.jks /app/cassandra_truststore.jks

EXPOSE 8000

ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseContainerSupport", "-Djava.security.egd=file:/dev/./urandom","-jar","/app/application.jar"]

This is my Interface

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>public interface VisitorsRepository extends CassandraRepository<VisitorEntity, String> {}
</code>
<code>public interface VisitorsRepository extends CassandraRepository<VisitorEntity, String> {} </code>
public interface VisitorsRepository extends CassandraRepository<VisitorEntity, String> {}

this is my service, I created the bean manually so I don’t need @Service

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>@RequiredArgsConstructor
@Slf4j
public class VisitorService {
@Autowired
private VisitorsRepository repository;
public ApiResponse execute(VisitorDto dto){
return Mono.just(repository.save(VisitorMapper.dtoToEntity(dto)))
.map(visitorEntity ->
ResponseMapper.buildResponse(true, HttpStatus.CREATED.value(), HttpStatus.CREATED.getReasonPhrase(), HttpStatus.CREATED.value(), HttpStatus.CREATED.getReasonPhrase())
)
.doOnSuccess(m -> log.info("entity saved"))
.doOnError(error -> log.error("Error saving entity: " + error.getMessage()))
.onErrorResume(error -> Mono.error(new RuntimeException(error.getMessage()))).block();
}
}
</code>
<code>@RequiredArgsConstructor @Slf4j public class VisitorService { @Autowired private VisitorsRepository repository; public ApiResponse execute(VisitorDto dto){ return Mono.just(repository.save(VisitorMapper.dtoToEntity(dto))) .map(visitorEntity -> ResponseMapper.buildResponse(true, HttpStatus.CREATED.value(), HttpStatus.CREATED.getReasonPhrase(), HttpStatus.CREATED.value(), HttpStatus.CREATED.getReasonPhrase()) ) .doOnSuccess(m -> log.info("entity saved")) .doOnError(error -> log.error("Error saving entity: " + error.getMessage())) .onErrorResume(error -> Mono.error(new RuntimeException(error.getMessage()))).block(); } } </code>
@RequiredArgsConstructor
@Slf4j
public class VisitorService {

@Autowired
private VisitorsRepository repository;

public ApiResponse execute(VisitorDto dto){
    return Mono.just(repository.save(VisitorMapper.dtoToEntity(dto)))
            .map(visitorEntity ->
                            ResponseMapper.buildResponse(true, HttpStatus.CREATED.value(), HttpStatus.CREATED.getReasonPhrase(),     HttpStatus.CREATED.value(), HttpStatus.CREATED.getReasonPhrase())
                    )
            .doOnSuccess(m -> log.info("entity saved"))
            .doOnError(error -> log.error("Error saving entity: " + error.getMessage()))
            .onErrorResume(error -> Mono.error(new RuntimeException(error.getMessage()))).block();
}
}

this is the @Bean

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>@Configuration
public class ServiceConfiguration {
@Bean
public VisitorService getVisitorService(){
return new VisitorService();
}
}
</code>
<code>@Configuration public class ServiceConfiguration { @Bean public VisitorService getVisitorService(){ return new VisitorService(); } } </code>
@Configuration
public class ServiceConfiguration {

  @Bean
  public VisitorService getVisitorService(){
     return new VisitorService();
  }
}

this is my controller

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>@RestController
@CrossOrigin(origins = "*")
@RequestMapping(value = "/api")
@AllArgsConstructor
@Validated
@Slf4j
public class VisitorController {
private final VisitorService service;
@PostMapping("/create-visitor")
public ResponseEntity<ApiResponse> execute(@RequestBody @Valid VisitorDto dto){
try{
ApiResponse apiResponse = service.execute(dto);
return new ResponseEntity<ApiResponse>(apiResponse,HttpStatus.OK);
}catch (Exception e){
e.getStackTrace();
throw new BadRequestException(e.getMessage());
}
}
}
</code>
<code>@RestController @CrossOrigin(origins = "*") @RequestMapping(value = "/api") @AllArgsConstructor @Validated @Slf4j public class VisitorController { private final VisitorService service; @PostMapping("/create-visitor") public ResponseEntity<ApiResponse> execute(@RequestBody @Valid VisitorDto dto){ try{ ApiResponse apiResponse = service.execute(dto); return new ResponseEntity<ApiResponse>(apiResponse,HttpStatus.OK); }catch (Exception e){ e.getStackTrace(); throw new BadRequestException(e.getMessage()); } } } </code>
@RestController
@CrossOrigin(origins = "*")
@RequestMapping(value = "/api")
@AllArgsConstructor
@Validated
@Slf4j
public class VisitorController {

   private final VisitorService service;

   @PostMapping("/create-visitor")
   public ResponseEntity<ApiResponse> execute(@RequestBody @Valid VisitorDto dto){
      try{
          ApiResponse apiResponse = service.execute(dto);
          return new ResponseEntity<ApiResponse>(apiResponse,HttpStatus.OK);
      }catch (Exception e){
          e.getStackTrace();
          throw new BadRequestException(e.getMessage());
   }

  }
}

And this is the error

ConfigServletWebServerApplicationContext : Exception encountered during context initialization – cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘visitorController’ defined in URL [jar:nested:/app/application.jar/!BOOT-INF/classes/!/ipservice/controller/VisitorController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name ‘getVisitorService’: Unsatisfied dependency expressed through field ‘repository’: Error creating bean with name ‘visitorsRepository’ defined in ipservice.repository.VisitorsRepository defined in @EnableCassandraRepositories declared on CassandraConfig: Cannot resolve reference to bean ‘cassandraTemplate’ while setting bean property ‘cassandraTemplate’

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật