Spring Annotations Cheat Sheet Styled
Spring Annotations Cheat Sheet Styled
@Component
@Component
System.out.println("Service is running...");
@Controller
@Controller
@RequestMapping("/home")
return "home";
@Service
@Service
return "User";
}
@Repository
@Repository
@Autowired
@Service
@Autowired
@ComponentScan
@Configuration
@ComponentScan(basePackages = "com.example")
@Configuration
@Configuration
@Bean
public MyService myService() {
@Bean
@Configuration
@Bean
@Scope
@Component
@Scope("prototype")
@Qualifier
@Service
@Autowired
@Qualifier("userRepositoryV2")
}
@RequestMapping
@Controller
@RequestMapping("/user")
@RequestMapping("/list")
return "userList";
@RestController
@GetMapping("/user/{id}")
@PathVariable
@GetMapping("/user/{id}")
@RequestParam
Binds a method parameter to a query parameter.
@GetMapping("/user")
@RequestBody
@PostMapping("/user")
@ResponseBody
Indicates that the return value of a method should be bound to the HTTP response body.
@GetMapping("/user")
@ResponseBody
return "User";
@RestController
@RestController
@GetMapping("/hello")
@Transactional
@Service
@Transactional
// transfer logic
@EnableAutoConfiguration
@SpringBootApplication
@EnableAutoConfiguration
SpringApplication.run(Application.class, args);
@Value
@Component
@Value("${app.name}")
return appName;