News for hackers. Stuff that matters.
Re:Only 1 in 10 Oracle Java users want to stay with Big Red by npalli on Thursday January 30, 2025 @07:16PM (#42883565)
Good things eh? The simplest Spring Boot program (assuming you can handle maven after this). The fact that Spring Boot is the end result of lot of de-FactoryFactoryization of Java shows how god awful standard programming in Java is.

  package com.example.hello;

  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;

  @SpringBootApplication
  public class MainApplication {
      public static void main(String[] args) {
          SpringApplication.run(MainApplication.class, args);
      }
  }

  //controller file
  package com.example.hello;

  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;

  @RestController
  @RequestMapping("/api")
  public class HelloController {
  
      @GetMapping("/hello")
      public String sayHello() {
          return "Hello, World!";
      }
  }
Even C++ is better than this!!

  #include "crow.h"

  int main() {
      crow::SimpleApp app;

      CROW_ROUTE(app, "/api/hello")
      ([]() {
          return "Hello, World!";
      });
  
      app.port(8080).multithreaded().run();
  }

There are no comments on this comment yet.