随笔分类 - Java
摘要:If you were using Microservice with Spring Boot to build different REST API endpoints, context path might help you. For example, you have two endpoint
阅读全文
只有注册用户登录后才能阅读该文。
摘要:Aspect-Oriented Programming (AOP) complements Object-Oriented Programming (OOP) by providing another way of thinking about program structure. The key
阅读全文
摘要:Previously we use Application Context to get Bean and Dependenies injection. It is actually easier to use 'CommonLineRunner'. Main beneift is we can u
阅读全文
摘要:It is recommened to write unit testing with Mockito in Spring framework, because it is much faster with Spring framework test. But in case you can doi
阅读全文
摘要:For example, we want to test against a implemataion: We want to do the test with Java Context: 1. Bring in some dependencies: in pom.xml Create a new
阅读全文
摘要:In this post, we are going to see more functionalities in Mockito. Mock a List interface: Call multi times: First call, return 10, second times return
阅读全文
摘要:Previously we have seen how to do Unit testing with Mockito; In this post, we are going to see, using annotation from Mockito to make testing easier:
阅读全文
摘要:We have the implemetion: And we want to test agaisnst it:
阅读全文
摘要:Check the get started guid https://junit.org/junit5/docs/current/user-guide/#overview-getting-help
阅读全文
摘要:Let's say we have a extral app.proporites file which contains some extra configuration: We can read the extra propoties by using @Value("${xxx}") As y
阅读全文
摘要:Component Scan is important concept when we want to create Bean. Currently we know what, for the class, we want to create Bean from it, we need to add
阅读全文
摘要:We have the following example: The idea is to understand in different cases, how those instanse are created. Currently when running the application, w
阅读全文
摘要:When we use Bean to do autowired, it actually use singleton, so even we create multi instanses, they are the same: It print out: We can also tell Spri
阅读全文
摘要:In the example we have currently: The way we do Autowired is by '@Primary' decorator. It is clear that one implementation detail is the best, then we
阅读全文
摘要:Spring boot is really good for Dependencies injection by using Autowiring. Each class instancse in spring boot is called 'Bean', we can use 'Bean' to
阅读全文
摘要:JPA is just like a helper class for providing data for Controller, has method like 'findOne', 'findAll', 'saveAndFlush', 'delete'. in repository/Shipw
阅读全文
摘要:We need our data persistence with configuring our datasouce: In application.properties: " " tells to save the in memory data into a file called 'gs-sp
阅读全文
摘要:In pom.xml add dependency: Then in application.properties: Now, in the broswer, we can access h2 database though url: localhost:8080/h2
阅读全文
摘要:We can use different application properties application.properties: application-prod.properties: application-test.properties: We can setup different p
阅读全文