File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Spring_part_14/src/main/java/spring/oldboy/config Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ package spring .oldboy .config ;
2+
3+ /*
4+ Пусть данный файл будет предназначен для настройки
5+ других bean-ов для работы с БД через JPA (естественно
6+ это демо-код без сложной логики, для демонстрации
7+ работы аннотаций и только)
8+ */
9+
10+ import jakarta .annotation .PostConstruct ;
11+ import lombok .extern .slf4j .Slf4j ;
12+ import org .springframework .boot .context .properties .ConfigurationProperties ;
13+ import org .springframework .context .annotation .Bean ;
14+ import org .springframework .context .annotation .Conditional ;
15+ import org .springframework .context .annotation .Configuration ;
16+ import spring .oldboy .config .condition .JpaCondition ;
17+
18+ @ Slf4j
19+ @ Conditional (JpaCondition .class )
20+ @ Configuration
21+ public class JpaConfiguration {
22+
23+ @ PostConstruct
24+ void init () {
25+ log .info ("Jpa configuration is enabled" );
26+ }
27+
28+ @ Bean
29+ @ ConfigurationProperties (prefix = "db" )
30+ public DatabaseProperties databaseProperties () {
31+ return new DatabaseProperties ();
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments