SpringBoot required a bean of type ‘javagram.javagram.service.UserService’ that could not be found

Trying to run my Spring-boot app and building an app has been failing.

Issue

SpringBoot reports following error at start:

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-06-18T15:03:47.336-07:00 ERROR 34766 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of constructor in javagram.javagram.web.UserController required a bean of type 'javagram.javagram.service.UserService' that could not be found.


Action:

Consider defining a bean of type 'javagram.javagram.service.UserService' in your configuration.

Code

Following are my classes in package javagram.javagram.:

service.UserService

package javagram.javagram.service;
import java.util.UUID;
import org.springframework.stereotype.Service;
import javagram.javagram.exception.UserNotFoundException;
import javagram.javagram.model.DTO.request.UserRequest;
import javagram.javagram.model.DTO.response.UserResponse;
import javagram.javagram.model.entity.UserEntity;
import javagram.javagram.repository.UserRepository;
import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
public class UserService {
   
    private final UserRepository userRepository;
    
    public UserResponse get(UUID uuid) {
        UserEntity entity =    userRepository.findById(uuid).orElseThrow(UserNotFoundException::new);

        UserResponse response = new UserResponse();

        response.setFirstName(entity.getFirstName());
        response.setLastName(entity.getLastName());
        response.setProfileName(entity.getProfileName());
        response.setCreatedAt(entity.getCreatedAt());
        response.setEmail(entity.getEmail());
        response.setPassword(entity.getPassword());
    
        return response;
    }


    public UUID create(UserRequest request) {
        UserEntity entity = new UserEntity();
        entity.setId(UUID.randomUUID());
        entity.setFirstName(request.getFirstName());
        entity.setLastName(request.getLastName());
        entity.setProfileName(request.getProfileName());
        entity.setCreatedAt(request.getCreatedAt());
        entity.setEmail(request.getEmail());
        entity.setPassword(request.getPassword());
    
        userRepository.save(entity);

        return entity.getId();
    } 

    public boolean update(UUID uuid, UserRequest userRequest) {
        UserEntity entity = userRepository.findById(uuid).orElseThrow(UserNotFoundException::new);

        entity.setFirstName(userRequest.getFirstName());
        entity.setLastName(userRequest.getLastName());
        entity.setProfileName(userRequest.getProfileName());
        entity.setCreatedAt(userRequest.getCreatedAt());
        entity.setEmail(userRequest.getEmail());
        entity.setPassword(userRequest.getPassword());

        userRepository.save(entity);

        return true;
    }

    }

web.JavagramApplication

package javagram.javagram.web;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
public class JavagramApplication {


    public static void main(String[] args) {
        SpringApplication.run(JavagramApplication.class, args);

    }
    
}

web.UserController

package javagram.javagram.web;

import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import javagram.javagram.model.DTO.request.UserRequest;
import jakarta.validation.Valid;
import javagram.javagram.service.UserService;
import lombok.RequiredArgsConstructor;
import java.util.UUID;

@Controller
@RequiredArgsConstructor
@RequestMapping("/users")
public class UserController {


    private final UserService userService;

  @GetMapping("/users/{uuid}")
    public ResponseEntity<?> get(@PathVariable UUID uuid) {
        return ResponseEntity.ok(userService.get(uuid));
    }

    @PostMapping("/users")
    public ResponseEntity<?> create(@Valid @RequestBody UserRequest request) {
        return ResponseEntity.ok(userService.create(request));
    }

    @PutMapping("/user/{uuid}")
    public ResponseEntity<?> update(@PathVariable UUID uuid, @Valid @RequestBody UserRequest userRequest) {
        userService.update(uuid, userRequest);
        return new ResponseEntity<>(HttpStatusCode.valueOf(200));
    }


    
}

Question

How can the app recognize the missing bean UserService?

1

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