Skip to content

Instantly share code, notes, and snippets.

@margielm
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save margielm/b10fffce7502a84ea23f to your computer and use it in GitHub Desktop.
Save margielm/b10fffce7502a84ea23f to your computer and use it in GitHub Desktop.
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application {
@Autowired
private UserRepository repository;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
InitializingBean init() {
return () -> {
repository.save(new User("John", "Smith"));
};
}
}
@dmnk89
Copy link

dmnk89 commented Feb 19, 2015

nie lepiej by bylo jak poniżej?

@Bean
InitializingBean init(UserRepository repository) {
  return () -> {
    repository.save(new User("John", "Smith"));
  };
} 

@margielm
Copy link
Author

może być i tak, chodziło o koncept i użycie InitializingBean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment