<div dir="ltr" style="text-align: justify;">In this spring rest tutorial, we will create restful web services Crud APIs by using HTTP verbs GET, POST, PUT and Delete and returning JSON representations of resources. In my previous post, we have created a very simple <a href="https://dineshonjava.com/restful-web-services-with-jersey-jax-rs/"><b>JAX-RS Restful web services</b></a> but in this post we are using Spring REST, it will return response as json in this example. If you want to learn more about REST you could read my previous article<b> <a href="https://dineshonjava.com/what-is-rest-and-rest-architecture-and-rest-constraints/">What is REST? Architecture and it&#8217;s Constraints</a></b>.</p>
<div id="ads-id" align="center"></div>
<p>Here we are using Spring 4.3.5 webmvc, Spring REST, Spring Data JPA and jackson libraries for this example. For back-end we are using H2 in-memory database for saving the data and also using Spring Data JPA over the Hibernate JPA as ORM. Let&#8217;s see steps to create a simple Spring Restful web services crud example which will return json.</p>
<h2><b>Step 1: Create a Dynamic web project using maven.</b><br />
<b><br />
</b> <b>Project Structure</b></h2>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2017/03/Spring-Restful-CRUD-JSON-Example.jpg" border="0" /></div>
<h2><b>Download Source Code from GitHub</b><br />
<a href="https://github.com/dineshonjava/SpringREST-CRUD-Example" target="_blank" rel="noopener"><b>Spring Restful Web Services JSON CRUD Example</b></a></h2>
<div style="background-color: #f2f9fc; border: 1px solid #c9e6f2; border-radius: 3px; padding: 16px; line-height: 1.45;"><span style="color: red; font-size: x-large; text-align: center;"><b>Popular Tutorials</b></span></p>
<ul style="text-align: left;">
<li><b><a href="https://dineshonjava.com/spring-tutorial/"><em><strong>Spring Tutorial</strong> </em></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-web-mvc-framework-chapter-38/"><strong><em>Spring MVC Web Tutorial </em></strong></a></b></li>
<li><b><a href="https://dineshonjava.com/introduction-to-spring-boot-a-spring-boot-complete-guide/"><strong>Spring Boot Tutorial</strong> </a></b></li>
<li><b><a href="https://dineshonjava.com/spring-security-take-baby-step-to-secure/"><em>Spring Security Tutorial</em></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-aop-tutorial-with-example-aspect-advice-pointcut-joinpoint/"><em>Spring AOP Tutorial</em></a></b></li>
<li><b><a href="https://dineshonjava.com/using-spring-jdbc-framework-chapter-32/"><em>Spring JDBC Tutorial</em></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-hateoas-hypermedia-driven-restful-web-service/"><em><strong>Spring HATEOAS </strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/microservices-with-spring-boot/"><em><strong>Microservices with Spring Boot</strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/jax-rs-web-service-tutorial/"><strong><em>REST Webservice</em> </strong></a></b></li>
<li><b><a href="https://dineshonjava.com/core-java-baby-step-to-be-best-java-ian/"><em><strong>Core Java </strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/hibernate-3-on-baby-steps/"><em><strong>Hibernate Tutorial</strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-batch-process-with-example/"><strong><em>Spring Batch</em> </strong></a></b></li>
</ul>
</div>
<h2>
<b>Step 2: Maven dependency for this application.</b></h2>
<p>In pom.xml, there are following dependency required for this application.</p>
<pre class="highlight"><;properties>; 
 <;spring.version>;4.3.5.RELEASE<;/spring.version>; 
 <;spring.data.version>;1.11.1.RELEASE<;/spring.data.version>; 
 <;h2.version>;1.4.193<;/h2.version>; 
 <;/properties>; 
 
 <;dependencies>; 
 <;dependency>; 
 <;groupId>;org.springframework<;/groupId>; 
 <;artifactId>;spring-webmvc<;/artifactId>; 
 <;version>;${spring.version}<;/version>; 
 <;/dependency>; 
 
 <;dependency>; 
 <;groupId>;org.springframework.data<;/groupId>; 
 <;artifactId>;spring-data-jpa<;/artifactId>; 
 <;version>;${spring.data.version}<;/version>; 
 <;/dependency>; 
 
 <;dependency>; 
 <;groupId>;com.h2database<;/groupId>; 
 <;artifactId>;h2<;/artifactId>; 
 <;version>;${h2.version}<;/version>; 
 <;/dependency>; 
 
 <;dependency>; 
 <;groupId>;org.hibernate<;/groupId>; 
 <;artifactId>;hibernate-entitymanager<;/artifactId>; 
 <;version>;5.1.0.Final<;/version>; 
 <;/dependency>; 
 
 <;!-- Jackson JSON Mapper -->; 
 <;dependency>; 
 <;groupId>;org.codehaus.jackson<;/groupId>; 
 <;artifactId>;jackson-mapper-asl<;/artifactId>; 
 <;version>;1.7.1<;/version>; 
 <;/dependency>; 
 <;dependency>; 
 <;groupId>;com.fasterxml.jackson.core<;/groupId>; 
 <;artifactId>;jackson-databind<;/artifactId>; 
 <;version>;2.5.0<;/version>; 
 <;/dependency>; 
 <;/dependencies>; 
</pre>
<p>In the maven file we have dependencies of spring webmvc, spring data jpa, h2 database and hibernate entity manager for jpa transaction. Also we have to include jackson maven dependencies into classpath of your application because spring will register <b><i>Jackson2JsonMessageConverter </i></b>class automatically into context. Whenever we request resource as json with accept <b><i>headers=&#8221;Accept=application/json&#8221;</i></b>, then <b><i>Jackson2JsonMessageConverter </i></b>comes into picture and convert resource to json format.</p>
<pre class="highlight"><;dependency>; 
 <;groupId>;com.fasterxml.jackson.core<;/groupId>; 
 <;artifactId>;jackson-databind<;/artifactId>; 
 <;version>;2.5.0<;/version>; 
<;/dependency>; 
</pre>
<h2><b>Step 3: Creating Spring Configuration files for this application</b></h2>
<p>In this spring restful web service application, we are using Java based configuration. So let&#8217;s see following configuration java classes for this example.</p>
<h3><b>a) Spring Configuration class for Spring MVC </b></h3>
<p>The following file is required for configuring spring mvc to the application and enabling required bean post processors for message converter.</p>
<p><b>RestApplicationConfig.java</b></p>
<pre class="highlight">/** 
 * 
 */ 
package com.doj.restapi.web.config; 
 
import org.springframework.context.annotation.ComponentScan; 
import org.springframework.context.annotation.Configuration; 
import org.springframework.web.servlet.config.annotation.EnableWebMvc; 
 
/** 
 * @author Dinesh.Rajput 
 * 
 */ 
@Configuration 
@EnableWebMvc 
@ComponentScan("com.doj.restapi.web.controller") 
public class RestApplicationConfig{ 
 
} 
</pre>
<p><b>@EnableWebMvc- </b>It used for enabling spring mvc behavior i.e. it is responsible for registering Spring MVC required Bean Post Processors in the application as like Jackson2JsonMessageConverter etc.<br />
<b>@ComponentScan- </b>It scans the package com.doj.restapi.web.controller. This package has Rest Controllers for this application.</p>
<h3><b>b) Spring Configuration for application Infrastructure</b></h3>
<p>This file has configuration about application core services like DB connection, DataSource and also scan the packages for service classes and repositories i.e. Non web components.</p>
<p><b>InfrastructureConfig.java</b></p>
<pre class="highlight">/** 
 * 
 */ 
package com.doj.restapi.config; 
 
import javax.persistence.EntityManagerFactory; 
import javax.sql.DataSource; 
 
import org.springframework.context.annotation.Bean; 
import org.springframework.context.annotation.ComponentScan; 
import org.springframework.context.annotation.Configuration; 
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; 
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; 
import org.springframework.orm.jpa.JpaTransactionManager; 
import org.springframework.orm.jpa.JpaVendorAdapter; 
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; 
import org.springframework.orm.jpa.vendor.Database; 
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; 
 
/** 
 * @author Dinesh.Rajput 
 * 
 */ 
@Configuration 
@ComponentScan("com.doj.restapi.service") 
@EnableJpaRepositories("com.doj.restapi.repository") 
public class InfrastructureConfig { 
 
 @Bean 
 public DataSource dataSource() { 
 return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build(); 
 } 
 
 @Bean 
 public JpaVendorAdapter jpaVendorAdapter() { 
 HibernateJpaVendorAdapter bean = new HibernateJpaVendorAdapter(); 
 bean.setDatabase(Database.H2); 
 bean.setGenerateDdl(true); 
 return bean; 
 } 
 
 @Bean 
 public LocalContainerEntityManagerFactoryBean entityManagerFactory( 
 DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) { 
 LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean(); 
 bean.setDataSource(dataSource); 
 bean.setJpaVendorAdapter(jpaVendorAdapter); 
 bean.setPackagesToScan("com.doj.restapi.bean"); 
 return bean; 
 } 
 
 @Bean 
 public JpaTransactionManager transactionManager(EntityManagerFactory emf) { 
 return new JpaTransactionManager(emf); 
 } 
} 
</pre>
<p><b>@EnableJpaRepositories-</b>It used to create the spring bean related to spring data jpa in the application i.e. those classes which implement spring data repository interfaces.</p>
<h2><b>Step 4: Creating Web Application Initializer file for this application</b></h2>
<p>Here we are using Java based configuration for web application i.e. here we do not have web.xml file in the application. For java based web configuration, we have to required at least tomcat 7 and servlet 3.0 or above.</p>
<p><b>RestApplicationInitializer.java</b></p>
<pre class="highlight">/** 
 * 
 */ 
package com.doj.restapi.web; 
 
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 
 
import com.doj.restapi.config.InfrastructureConfig; 
import com.doj.restapi.web.config.RestApplicationConfig; 
 
/** 
 * @author Dinesh.Rajput 
 * 
 */ 
public class RestApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 
 
 @Override 
 protected Class<;?>;[] getRootConfigClasses() { 
 return new Class[] { InfrastructureConfig.class }; 
 } 
 
 @Override 
 protected Class<;?>;[] getServletConfigClasses() { 
 return new Class[] { RestApplicationConfig.class }; 
 } 
 
 @Override 
 protected String[] getServletMappings() { 
 return new String[] { "/" }; 
 } 
} 
 
</pre>
<h2><b>Step 5: Creating Application classes</b></h2>
<p>In this application, we will create and read account resource from account repository.<br />
<b>a) Create a Controller <i>AccountController.java</i></b></p>
<pre class="highlight">/** 
 * 
 */ 
package com.doj.restapi.web.controller; 
 
import java.util.List; 
 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.web.bind.annotation.DeleteMapping; 
import org.springframework.web.bind.annotation.GetMapping; 
import org.springframework.web.bind.annotation.PathVariable; 
import org.springframework.web.bind.annotation.PostMapping; 
import org.springframework.web.bind.annotation.PutMapping; 
import org.springframework.web.bind.annotation.RequestBody; 
import org.springframework.web.bind.annotation.RestController; 
 
import com.doj.restapi.bean.Account; 
import com.doj.restapi.service.IAccountService; 
 
/** 
 * @author Dinesh.Rajput 
 * 
 */ 
@RestController 
public class AccountController { 
 
 @Autowired 
 IAccountService accountService; 
 
 @GetMapping("/") 
 public String home (){ 
 return "Spring REST Dinesh on Java!!!"; 
 } 
 
 @GetMapping("/accounts") 
 public List<;Account>; all (){ 
 return accountService.list(); 
 } 
 
 @PostMapping("/account") 
 public Account create (@RequestBody Account account){ 
 return accountService.create(account); 
 } 
 
 @GetMapping("/account/{accountId}") 
 public Account get (@PathVariable Long accountId){ 
 return accountService.get(accountId); 
 } 
 
 @PutMapping("/account/{accountId}") 
 public Account update (@RequestBody Account account, @PathVariable Long accountId){ 
 return accountService.update(account, accountId); 
 } 
 
 @DeleteMapping("/account/{accountId}") 
 public void delete (@PathVariable Long accountId){ 
 accountService.delete(accountId); 
 } 
} 
 
</pre>
<p>This controller class is annotated with @RestController annotation instead of @Controller annotation. As of spring 4.0, we can use @RestController which is combination of @Controller and @ResponseBody. Read my article<b> <a href="https://dineshonjava.com/2014/02/restcontroller-in-spring-40-framework.html">RestController in Spring Framework 4.0</a></b> for more detail.</p>
<pre class="highlight">@RestController = @Controller + @ResponseBody 
</pre>
<p>Before Spring 4.0, we have to use @Controller at the class level with @ResponseBody before the handler method as below:</p>
<pre class="highlight">@Controller 
public class AccountController { 
..... 
..... 
 
@RequestMapping("/account/{accountId}") 
public @ResponseBody Account get (@PathVariable Long accountId){ 
 return accountService.get(accountId); 
} 
..... 
..... 
} 
</pre>
<p>In this example, we are using @GetMapping, @PostMapping, @PutMapping and @DeleteMapping annotations, these annotations are introduced from Spring 4.3 version in parallel of @RequestMapping with Http Methods annotation as below.</p>
<pre class="highlight">@GetMapping = @RequestMapping + Http GET method 
</pre>
<p><b>b) Create a Bean class <i>Account.java</i></b></p>
<pre class="highlight">/** 
 * 
 */ 
package com.doj.restapi.bean; 
 
import java.io.Serializable; 
 
import javax.persistence.Entity; 
import javax.persistence.GeneratedValue; 
import javax.persistence.Id; 
import javax.persistence.Table; 
 
/** 
 * @author Dinesh.Rajput 
 * 
 */ 
@Entity 
@Table 
public class Account implements Serializable{ 
 
 /** 
 * 
 */ 
 private static final long serialVersionUID = 1L; 
 @Id 
 @GeneratedValue 
 public Long accountId; 
 public String name; 
 public String city; 
 public Double balance; 
 
 public Account() { 
 super(); 
 } 
 public Account(String name, String city, Double balance) { 
 super(); 
 this.name = name; 
 this.city = city; 
 this.balance = balance; 
 } 
 public Long getAccountId() { 
 return accountId; 
 } 
 public void setAccountId(Long accountId) { 
 this.accountId = accountId; 
 } 
 public String getName() { 
 return name; 
 } 
 public void setName(String name) { 
 this.name = name; 
 } 
 public String getCity() { 
 return city; 
 } 
 public void setCity(String city) { 
 this.city = city; 
 } 
 public Double getBalance() { 
 return balance; 
 } 
 public void setBalance(Double balance) { 
 this.balance = balance; 
 } 
 @Override 
 public String toString() { 
 return "Account [accountId=" + accountId + ", name=" + name + ", city=" + city + ", balance=" + balance + "]"; 
 } 
 
} 
 
</pre>
<p><b>c) Create a Service class <i>AccountService.java</i></b><br />
This class has CRUD method service for account resource.</p>
<pre class="highlight">/** 
 * 
 */ 
package com.doj.restapi.service; 
 
import java.util.List; 
 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.stereotype.Service; 
 
import com.doj.restapi.bean.Account; 
import com.doj.restapi.repository.AccountRepository; 
 
/** 
 * @author Dinesh.Rajput 
 * 
 */ 
@Service 
public class AccountService implements IAccountService{ 
 
 @Autowired 
 AccountRepository accountRepository; 
 
 @Override 
 public Account create(Account account) { 
 return accountRepository.save(account); 
 } 
 
 @Override 
 public Account get(Long accountId) { 
 return accountRepository.findOne(accountId); 
 } 
 
 @Override 
 public Account update(Account account, Long accountId) { 
 return accountRepository.save(account); 
 } 
 
 @Override 
 public void delete(Long accountId) { 
 accountRepository.delete(accountId); 
 } 
 
 @Override 
 public List<;Account>; list() { 
 return (List<;Account>;) accountRepository.findAll(); 
 } 
} 
 
</pre>
<p><b>d) Create a Repository class <i>AccountRepository.java</i></b><br />
This is an interface which extends an interface of Spring Data JPA for using CRUD operation over account class.</p>
<pre class="highlight">/** 
 * 
 */ 
package com.doj.restapi.repository; 
 
import org.springframework.data.repository.CrudRepository; 
 
import com.doj.restapi.bean.Account; 
 
/** 
 * @author Dinesh.Rajput 
 * 
 */ 
public interface AccountRepository extends CrudRepository<;Account, Long>; { 
 
} 
 
</pre>
<p>This interface is extending an interface CrudRepository of Spring Data JPA library. As you seen, there is no method in the interface, so we are using default CRUD operation methods of CrudRepository interface.</p>
<h2><b>Step 6: Deploying this application to tomcat server</b></h2>
<p><b>Right click on project ->; run as ->; run on server</b></p>
<p>After starting of tomcat server, Let&#8217;s check our application with Rest client <b>Postman</b>, it is UI based client for testing restful web applications, we have below URL of our application to provide start page:</p>
<p><b>a) Home Page</b><br />
<i><b>http://localhost:8080/restapi/</b></i></p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2017/03/rest-home-page.jpg" border="0" /></div>
<p><b>Postman</b> is chrome plugin. Launch postman.<br />
<b>b) POST method: CREATE Account Resource using POST http method</b><br />
Post method is used to create new resource. Here we are adding new Account to the account database, so you can see we have used account json in post body.</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2017/03/Create-resource-POST-method.jpg" border="0" /></div>
<p><b>c) GET method: READ Account Resource using GET http method</b><br />
Test our get method Spring REST service. You will get following output as below:</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2017/03/Read-Resource-Http-GET.jpg" border="0" /></div>
<p><b>d) PUT method: UPDATE Account Resource using PUT http method</b><br />
Put method is used to update resource. Here we will update name of account holder of accountId=1 using put method. So we will update account json in body of request of accountId is 1 as below.</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2017/03/Update-resource-PUT-method.jpg" border="0" /></div>
<p><b>e) DELETE method: DELETE Account Resource using DELETE http method</b><br />
Delete method is used to delete resource. So here we will pass accountId of account which needs to be deleted as Path Param. We are going delete the account who have accountId=3.</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2017/03/Delete-account-resource-delete-method.jpg" border="0" /></div>
<p><b>f) Read All Account Resources using GET http method</b></p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2017/03/List-Resources-GET-method-http.jpg" border="0" /></div>
<div style="background-color: #f2f9fc; border: 1px solid #c9e6f2; border-radius: 3px; padding: 16px; line-height: 1.45;"><span style="color: red; font-size: x-large; text-align: center;"><b>Spring MVC Related Posts</b></span></p>
<ul>
<li><b><a href="https://dineshonjava.com/spring-web-mvc-framework-chapter-38/"><span style="color: red;">Spring MVC Web Tutorial</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-mvc-interview-questions-and-answers/"><span style="color: red;">Spring MVC Interview Questions</span></a></b></li>
<li><b><a href="https://dineshonjava.com/introduction-to-mvc/"><span style="color: red;">MVC Design Pattern</span></a></b></li>
<li><b><a href="https://dineshonjava.com/what-is-dispatcherservlet-in-spring-and-its-uses/"><span style="color: red;">Spring MVC DispatcherServlet </span></a></b></li>
<li><b><a href="https://dineshonjava.com/difference-between-applicationcontext-webapplicationcontext-in-spring-mvc/"><span style="color: red;">Spring MVC WebApplicationContext and Root Application Context</span></a></b></li>
<li><b><a href="https://dineshonjava.com/stereotype-annotations-in-spring/"><span style="color: red;">Spring MVC @Controller Annotation</span></a></b></li>
<li><b><a href="https://dineshonjava.com/requestmapping-annotation-in-spring-mvc/"><span style="color: red;">Spring MVC @RequestMapping Annotation</span></a></b></li>
<li><b><a href="https://dineshonjava.com/requestparam-annotation-in-spring-mvc-with-example/"><span style="color: red;">Spring MVC @RequestParam Annotation</span></a></b></li>
<li><b><a href="https://dineshonjava.com/difference-between-applicationcontext-webapplicationcontext-in-spring-mvc/"><span style="color: red;">Spring MVC ContextLoaderListener</span></a></b></li>
<li><b><a href="https://dineshonjava.com/requestparam-vs-pathvariable-annotations-in-spring-mvc/"><span style="color: red;">Spring MVC @RequestParam and @PathVariable annotations</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-30-mvc-hello-world-example/"><span style="color: red;">Spring MVC Hello World Example</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-exception-handling-example/"><span style="color: red;">Spring MVC Exception Handling Example</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-mvc-with-hibernate-crud-example/"><span style="color: red;">Spring MVC with Hibernate CRUD Example</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-3-mvc-tiles-plugin-with-example/"><span style="color: red;">Spring MVC Tiles Plugin with Example</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-3-mvc-and-interceptor-with/"><span style="color: red;">Spring MVC Interceptor with example</span></a></b></li>
<li><b><a href="https://dineshonjava.com/integration-spring-mvc3-and-mongodb/"><span style="color: red;">Spring MVC with MongoDB CRUD Example</span></a></b></li>
<li><b><a href="https://dineshonjava.com/spring-3-mvc-internationalization/"><span style="color: red;">Spring MVC Internationalization &; Localization with Example</span></a></b></li>
</ul>
<p> ;</p>
</div>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/what-is-rest-and-rest-architecture-and-rest-constraints/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/spring-rest-client-resttemplate-consume-restful-web-service-example-json/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '41'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…