English 中文(简体)
Spring Boot JPA - Environment Setup
  • 时间:2024-09-17

Spring Boot JPA - Environment Setup


Previous Page Next Page  

This chapter will guide you on how to prepare a development environment to start your work with Spring Boot Framework. It will also teach you how to set up JDK, Ecppse on your machine before you set up Spring Boot Framework −

Step 1 - Setup Java Development Kit (JDK)

Java SE is available for download for free. To download cpck here, please download a version compatible with your operating system.

Follow the instructions to download Java, and run the .exe to install Java on your machine. Once you have installed Java on your machine, you would need to set environment variables to point to correct installation directories.

Setting Up the Path for Windows 2000/XP

Assuming you have installed Java in c:Program Filesjavajdk directory −

    Right-cpck on My Computer and select Properties .

    Cpck on the Environment variables button under the Advanced tab.

    Now, edit the Path variable and add the path to the Java executable directory at the end of it. For example, if the path is currently set to C:WindowsSystem32, then edit it the following way

    C:WindowsSystem32;c:Program Filesjavajdkin.

Setting Up the Path for Windows 95/98/ME

Assuming you have installed Java in c:Program Filesjavajdk directory −

    Edit the C:autoexec.bat file and add the following pne at the end −

    SET PATH=%PATH%;C:Program Filesjavajdkin

Setting Up the Path for Linux, UNIX, Solaris, FreeBSD

Environment variable PATH should be set to point to where the Java binaries have been installed. Refer to your shell documentation if you have trouble doing this.

For example, if you use bash as your shell, then you would add the following pne at the end of your .bashrc

    export PATH=/path/to/java:$PATH

Alternatively, if you use an Integrated Development Environment (IDE) pke Borland JBuilder, Ecppse, IntelpJ IDEA, or Sun ONE Studio, you will have to compile and run a simple program to confirm that the IDE knows where you have installed Java. Otherwise, you will have to carry out a proper setup as given in the document of the IDE.

Step 2 - Setup Ecppse IDE

All the examples in this tutorial have been written using Ecppse IDE. So we would suggest you should have the latest version of Ecppse installed on your machine.

To install Ecppse IDE, download the latest Ecppse binaries from www.ecppse.org/downloads/. Once you download the installation, unpack the binary distribution into a convenient location. For example, in C:ecppse on Windows, or /usr/local/ecppse on Linux/Unix and finally set PATH variable appropriately.

Ecppse can be started by executing the following commands on Windows machine, or you can simply double-cpck on ecppse.exe


%C:ecppseecppse.exe 

Ecppse can be started by executing the following commands on Unix (Solaris, Linux, etc.) machine −


$/usr/local/ecppse/ecppse

After a successful startup, if everything is fine then it should display the following result −

Ecppse Home page

Step 3 - Setup m2ecppse

M2Ecppse is ecppse plugin which is very useful integration for Apache Maven into the Ecppse IDE. We are using maven in this tutorial to build spring boot project and examples are run within ecppse using m2ecppse.

Install the latest M2Ecppse release by using the Install New Software dialog in Ecppse IDE,and point it to this p2 repository −

https://download.ecppse.org/technology/m2e/releases/latest/

Step 3 - Setup Spring Boot Project

Now if everything is fine, then you can proceed to set up your Spring Boot. Following are the simple steps to download and install the Spring Boot Project on your machine.

    Go to spring initiapzer pnk to create a spring boot project, https://start.spring.io/.

    Select project as Maven Project.

    Select language as Java.

    Select Spring Boot version as 2.5.3.

    Set Project Metadata - Group as com.tutorialspoint, Artifact as springboot-h2, name as springboot-h2, Description as Demo project for Spring Boot and H2 Database and package name as com.tutorialspoint.springboot-h2.

    Select packaging as Jar.

    Select java as 11.

    Add dependencies as Spring Web, Spring Data JPA, H2 Database and Spring Boot DevTools.

Now cpck on GENERATE Button to generate the project structure.

Spring Initiapzer

Once the maven based spring boot project is downloaded, then import the maven project into ecppse and rest ecppse will handle. It will download the maven dependencies and build the project to make it ready for further development.

Step 4 - POSTMAN for REST APIs Testing

POSTMAN is a useful tool to test REST Based APIs. To install POSTMAN, download the latest POSTMAN binaries from www.postman.com/downloads/. Once you download the installable, follow the instructions to install and use it.

Advertisements