随笔分类 - Java
摘要:Controller: Code below shows a basic Controller to handle GET, POST; DELETE, PUT requests. Model: Im memory data: This is just a mock data. package he
阅读全文
摘要:In Spring boot, define a REST API endpoint is pretty easy.
阅读全文
摘要:We might have some project specific configuration need to setup. The good approach to do this in Sprint is using 'Proptries'. In resouces/applicationC
阅读全文
摘要:We can define a class to be Singleton or Prototype. If the class was defined as Prototype, then everytime when we use new keyword, it will create a ne
阅读全文
摘要:There is no applicationContext.xml file. Too much XML Namespaces helped Enter Java Configuration Create main/java/com.pluralsight/AppConfig.java: 1. S
阅读全文
摘要:Add context to our application. main/resources/applicationContext.xml: Using annotation for @Service @Repository @Controller: /repository/HibernateCus
阅读全文
摘要:Previous we have seen constructore injection: https://www.cnblogs.com/Answer1215/p/9484872.html It would be easier to using autowire to reduce the cod
阅读全文
摘要:Previous we see how to do Setter injection: https://www.cnblogs.com/Answer1215/p/9472117.html Now let's see how to cover setter injection to coustruct
阅读全文
摘要:In CustomerServiceImpl.java, we hardcoded 'HibernateCustomerRepositoryImpl' To remove hardcoded Repository, we can use Setter Injection. First, we def
阅读全文
摘要:We mainly need to modify our Model and REST endpoint code to enable swagger Document. model/Book.java: By doing this, we can get each model defination
阅读全文
摘要:1. We have the BookEndpoint.java: 2. Creating a test for the REST endpoint:
阅读全文
摘要:1. Create a rest folder with JAXRSConfiguration.java: 2. Create Endpoint file: BookEndpoint.java:
阅读全文
摘要:So what is a Bean, in JavaEE, any class expect Entity are Bean. One usefully thing in Bean is Dependency injection. Just like Angular, it is just a Cl
阅读全文
摘要:When we create Entity and Respority, we also need to do validations to protect our data. In Java, validations are built-in, using decorators. For Type
阅读全文
摘要:We have model like this: 1 package com.pluralsight.bookstore.model; 2 3 import javax.persistence.*; 4 import java.util.Date; 5 6 /** 7 * @author Anton
阅读全文
摘要:Mainly two things: 1. For all the creating and deleting opreations for the DB, we want to use 'REQUIRED' for the transaction. 2. For all the read only
阅读全文
摘要:To bootsrap the application use the following Maven archetype: mvn -DarchetypeGroupId=org.codehaus.mojo.archetypes -DarchetypeArtifactId=webapp-javaee
阅读全文
摘要:package com.learning; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; im
阅读全文