Skip to content

Commit

Permalink
Removed AppConfig.java, proper properties, Table annotation added
Browse files Browse the repository at this point in the history
  • Loading branch information
viacheslav-torbin committed Oct 14, 2023
1 parent 12cbfff commit 655bb1e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 70 deletions.
33 changes: 11 additions & 22 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,35 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.3.1.Final</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.224</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>6.0.11</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.9.0</version>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.33</version>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
43 changes: 0 additions & 43 deletions src/main/java/org/bookstore/config/AppConfig.java

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/java/org/bookstore/model/Book.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.math.BigDecimal;

@Entity
@Table(name = "books")
public class Book {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public Book save(Book book) {
@Override
public List<Book> findAll() {
try (Session session = sessionFactory.openSession()) {
return session.createQuery("from Book b", Book.class).getResultList();
return session.createQuery("from Book", Book.class).getResultList();
} catch (Exception e) {
throw new DataProcessingException("Can't get all books", e);
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.show-sql=true
db.driver-class-name=com.mysql.cj.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/db
db.username=slava
db.password=12345
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/db
spring.datasource.username=slava
spring.datasource.password=12345

0 comments on commit 655bb1e

Please sign in to comment.