Merge pull request 'hibernate-templ' (#1) from hibernate-templ into master
This commit is contained in:
commit
6620dc038b
@ -1 +1,2 @@
|
||||
docker-compose -f stack.yml up
|
||||
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id
|
||||
|
26
buisnesslogic/src/main/java/com/plannaplan/Book.java
Normal file
26
buisnesslogic/src/main/java/com/plannaplan/Book.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.plannaplan;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class Book {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
// standard constructors
|
||||
|
||||
// standard getters and setters
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.plannaplan;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface BookRepository extends JpaRepository<Book, Long> {
|
||||
}
|
17
buisnesslogic/src/main/java/com/plannaplan/BookService.java
Normal file
17
buisnesslogic/src/main/java/com/plannaplan/BookService.java
Normal file
@ -0,0 +1,17 @@
|
||||
package com.plannaplan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class BookService {
|
||||
|
||||
@Autowired
|
||||
private BookRepository bookRepository;
|
||||
|
||||
public List<Book> list() {
|
||||
return bookRepository.findAll();
|
||||
}
|
||||
}
|
@ -1,20 +1,24 @@
|
||||
package com.plannaplan;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
{
|
||||
/**
|
||||
* Rigorous Test :-)
|
||||
*/
|
||||
public class AppTest {
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void shouldAnswerWithTrue()
|
||||
{
|
||||
assertTrue( true );
|
||||
public void whenApplicationStarts_thenHibernateCreatesInitialRecords() {
|
||||
List<Book> books = bookService.list();
|
||||
|
||||
Assert.assertEquals(books.size(), 1);
|
||||
}
|
||||
}
|
||||
|
6
buisnesslogic/src/test/resources/application.properties
Normal file
6
buisnesslogic/src/test/resources/application.properties
Normal file
@ -0,0 +1,6 @@
|
||||
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
|
||||
spring.datasource.url=jdbc:mysql://172.20.0.2:3306/test
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=example
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
3
pom.xml
3
pom.xml
@ -78,7 +78,8 @@
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<modules> <module>buisnesslogic</module>
|
||||
<modules>
|
||||
<module>buisnesslogic</module>
|
||||
<module>restservice</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class TestController {
|
||||
@GetMapping("/")
|
||||
public String xd() {
|
||||
SampleClass xd = new SampleClass("hedhadhsbajkd");
|
||||
return "<h1>" + xd.getXd() + "</h1>";
|
||||
return "<h1>xd</h1>";
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
|
||||
spring.datasource.url=jdbc:mariadb://localhost:3306/test
|
||||
spring.datasource.url=jdbc:mysql://172.20.0.2:3306/test
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=example
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
||||
spring.jpa.hibernate.ddl-auto=create
|
||||
|
||||
server.port=1285
|
Loading…
Reference in New Issue
Block a user