Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SpringBootApplication
- @Slf4j
- public class Application {
- @Entity
- @Data
- static class MyEntity {
- @Id
- @GeneratedValue
- private String id;
- }
- @Repository
- interface MyDao extends JpaRepository<MyEntity, String> {
- }
- @RequiredArgsConstructor
- @Component
- class MyService {
- private final MyDao dao;
- public void someMethod(){}
- }
- @RequiredArgsConstructor
- @Transactional
- @Component
- static class MyTransactedService {
- private final MyDao dao;
- public void someMethod(){}
- }
- @Controller
- @RequiredArgsConstructor
- @Getter
- static class MyController {
- private final MyService myService;
- private final MyTransactedService myTransactedService;
- }
- public static void main(String[] args) {
- ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
- MyController myController = context.getBean(MyController.class);
- MyService myService = myController.getMyService();
- MyTransactedService myTransactedService = myController.getMyTransactedService();
- log.info("myController bean class: {}", myController.getClass());
- log.info("myService bean class: {}", myService.getClass());
- log.info("myTransactedService bean class: {}", myTransactedService.getClass());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement