Spring Boot-301 Flashcards
What is spring.provides
Each starter has a spring .provides file, which tells by using this starter package what we will get it : spring-test, spring-boot, spring-junit…
What is the nomenclature for starter pack?
spring-boot-starter-[…](web, data,
What is a CommandLineRunner
scan all components and invokes
How can we the Order of invokation of beans?
@Order or implement and Ordered IF
Is there a IN to extends in corresponding to each @Spring Annotation
Yes , extend it and customize
Does Boot creates the DataSource automatically?
Yes the Boot will create DS for H2, Derby , HSQL, just have to add one in CP
Show the class of SpringBootApplication ?
@Configuration @EnableAutoConfiguration @ComponentScan public Interface SpringBootApplication { }
Is SpringBootApplication an IF
Yes
What @Configuration does?
It says that @BEan, @ComponentScan & @Service
What @ComponentScan does?
It says that to scan all base packages for Spring annotaions. THe base package is the package the SpringBootApplication belongs to
What @EnableAutoConfiguratioon?
It composes of EnableAutoConfigurationalImmortSelecrtor
& ConfigurationPackages.Registrar to automatically configure the conditional beans
What does SpringApplication.run does?
It creates a Spring application context, that reads the annotations of class in parenthesis and instantiates
IS CommandLineInterface is and IF?
Yes
Which method CommandLineInterface has>?
Just one method public void run(String… args)
What is the relevance of run in CommandLineInterface
it just called once when SpringBoots
Which class is we have for DataOperations?
DataSource
Are there DB predefined properties for DS?
Yes in app.prop spring.datasource.url, spring.datasource.username, spring.datasource.password
and the like
IS it possible to configure DS external to Boot App, like JBoss, tomcat and the like ?
YEs by using spring.datasource.jndi-name
Can we use - in app.props ?
Yes and they get transalated to camel case
Can we configure the hibernate props also in app.props?
Yes, like spring.jpa.hibernate.ddl-auto=create-drop
Is DS can be wrapped onve JDBCTemplate?
Yes,
Use
@Autowired
private JdbcTemplate jdbcTemplate;
Which class is for DS?
org. springframework.boot.autoconfig-
ure. jdbc.DataSourceAutoConfiguration
How can we create a repository?
By extending CrudRepository
Name some annotations of Java persistence api?
@Entity, @Id, @GeneratedValue, @OneToMany, @ManyToOne, @ManyToMany