

Chọn Project Setting, hãy đảm bảo rằng project của bạn có SDK là 21 và language level là 21

Chọn Platform setting, hãy đảm bảo rằng platform SDK của bạn là 21

Mở file application.properties thêm vào server.port=8081 để cấu hình project chạy trên port 8081

Nhấn vào biểu tượng Run để chạy project, bạn có thể thấy project đang chạy trên port 8081

http://localhost:8080/actuator/health để kiểm tra
implementation 'org.springframework.boot:spring-boot-starter-log4j2'configurations {
configureEach {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
exclude group: 'commons-logging', module: 'commons-logging'
}
}

Trong thư mục com.firstcloudjourney.productsservice tạo folder products

Trong thư mục products tạo thư mục controllers và tạo file ProductsController.java từ thư mục controllers

@RestController
@RequestMapping("/api/products")
public class ProductsController {
private static final Logger LOG = LogManager.getLogger(ProductsController.class);
@GetMapping
public String getAllProducts() {
LOG.info("Get all products");
return "All products";
}
}

http://localhost:8081/api/products
