File tree 6 files changed +26
-26
lines changed
6 files changed +26
-26
lines changed Original file line number Diff line number Diff line change 95
95
<scope >"runtime</scope >
96
96
</dependency >
97
97
98
+ <dependency >
99
+ <groupId >io.micronaut.liquibase</groupId >
100
+ <artifactId >micronaut-liquibase</artifactId >
101
+ </dependency >
98
102
</dependencies >
99
103
100
104
<build >
109
113
<artifactId >maven-compiler-plugin</artifactId >
110
114
<configuration >
111
115
<!-- Uncomment to enable incremental compilation -->
112
- <!-- <useIncrementalCompilation>false</useIncrementalCompilation> -->
116
+ <!-- <useIncrementalCompilation>false</useIncrementalCompilation>-->
113
117
114
118
<annotationProcessorPaths combine.children=" append" >
115
119
<path >
Original file line number Diff line number Diff line change 3
3
import javax .persistence .*;
4
4
5
5
@ Entity
6
- public class Pen {
6
+ @ Table (name = "books" )
7
+ public class Book {
7
8
@ Id
8
- @ GeneratedValue (strategy = GenerationType .SEQUENCE )
9
+ @ GeneratedValue (strategy = GenerationType .IDENTITY )
9
10
private Long id ;
10
11
private String title ;
11
12
private int pages ;
12
13
13
- public Pen (String title , int pages ) {
14
+ public Book (String title , int pages ) {
14
15
this .title = title ;
15
16
this .pages = pages ;
16
17
}
17
18
18
- public Pen () {
19
+ public Book () {
19
20
}
20
21
21
22
public Long getId () {
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ public void init() {
18
18
}
19
19
20
20
@ Get ("/books" )
21
- public List <Pen > books () {
21
+ public List <Book > books () {
22
22
return service .findAll ();
23
23
}
24
24
Original file line number Diff line number Diff line change 1
1
package com .example ;
2
2
3
- import io .micronaut .core .annotation .NonNull ;
4
3
import io .micronaut .context .annotation .Executable ;
5
4
import io .micronaut .data .annotation .*;
6
- import io .micronaut .data .model .*;
7
5
import io .micronaut .data .repository .CrudRepository ;
8
6
9
- import javax .validation .Valid ;
10
- import javax .validation .constraints .NotNull ;
11
- import java .util .List ;
12
-
13
7
@ Repository //
14
- interface BookRepository extends CrudRepository <Pen , Long > {
8
+ interface BookRepository extends CrudRepository <Book , Long > {
15
9
16
10
@ Executable
17
- Pen find (String title );
11
+ Book find (String title );
18
12
19
13
20
14
Original file line number Diff line number Diff line change @@ -15,14 +15,14 @@ public class BookService {
15
15
16
16
public void initDataBase (){
17
17
18
- Pen book = new Pen ();
18
+ Book book = new Book ();
19
19
book .setTitle ("The Stand" );
20
20
book .setPages (1000 );
21
21
repository .save (book );
22
22
}
23
23
24
- public List <Pen > findAll (){
24
+ public List <Book > findAll (){
25
25
26
- return (List <Pen >) repository .findAll ();
26
+ return (List <Book >) repository .findAll ();
27
27
}
28
28
}
Original file line number Diff line number Diff line change 8
8
9
9
datasources :
10
10
default :
11
- url : jdbc:h2:mem:devDb
12
- driverClassName : org.h2.Driver
13
- username : sa
11
+ url : ' jdbc:h2:mem:liquibaseDisabledDb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=TRUE'
12
+ username : ' sa'
14
13
password : ' '
15
- schema-generate : CREATE_DROP
16
- dialect : H2
17
-
14
+ driverClassName : ' org.h2.Driver'
18
15
jpa :
19
16
default :
20
- entity -scan :
21
- packages : ' com.example'
17
+ packages-to -scan :
18
+ - ' com.example'
22
19
properties :
23
20
hibernate :
24
21
hbm2ddl :
25
22
auto : update
26
- show_sql : true
23
+ show_sql : true
24
+ liquibase :
25
+ datasources :
26
+ default :
27
+ change-log : ' classpath:db/liquibase-changelog.xml'
You can’t perform that action at this time.
0 commit comments