Java development environment construction (Mac + Pleiades All in One Eclipse 4.7 + Spring Boot + Gradle (Buildship))

Introduction

Now that we have built a Java development environment on Mac, the steps are summarized below. It describes until "Hello World" is output.

Prerequisites

In Pleiades All in One Eclipse, with the automatic default setting function, The path of the compiler etc. is set automatically without depending on the existing JDK environment. Therefore, you don't need a JDK, but if you are interested in an older version of the JDK, Please delete it in advance according to the procedure of reference information (How to uninstall JDK).

  1. Eclipse

1-1. Download

Download Pleiades All in One Eclipse from the following site.  http://mergedoc.osdn.jp/

(1) Select Eclipse 4.7 Oxygen. Screenshot 01.png

(2) Select Mac 64bit (Full Edition) and Java. Screenshot 02.png

1-2. Installation

(1) Execute pleiades-4.7.2-java-mac-jre_20171225.dmg. (2) Drag and drop it on Applications. Screenshot 03.png

1-3. Start up

At the first startup, a warning "Cannot open because the developer has not been confirmed" may be displayed. Screenshot 04.png

In that case, if you right-click to open it, the following dialog will be displayed, so Click "Open". From the second time onward, this warning will not be displayed. Screenshot 05.png

Select any directory for the workspace.

  1. Spring Tool Suite(STS) Install the plugin for Spring development in Eclipse. Spring-Boot will also be developed with this.

(1) Select Help → Eclipse Marketplace from the menu. Screenshot 07.png

(2) Search for "STS" and install. Screenshot 08.png

(3) On the confirmation screen of the selected feature, just press the confirmation button. (4) On the license review screen, select "I accept the terms of the terms of use" and click the Finish button.

This is because the locally cached server information is out of date. Please update the server information according to the procedure of reference information (update server information). After updating, if you install again, you can install without error.

(5) Right-click on Package Explorer → New → Other You can see that Spring and Spring Boot have been added. Screenshot 11.png

3. Create a project

Created in the Spring Starter project.

(1) Creating a project File → New → Other → Select Spring Starter Project (2) Except for selecting "Gradle (Buildship 2.x)" as the type, proceed to "Next" with the default settings. Screenshot 31.png

(3) Select "Web" and proceed to "Next".   32.png

(4) Finally, a confirmation screen will be displayed. Click the "Finish" button.

4. Confirmation of the project

(1) Execution of the project Right-click on the project → Run → Spring Boot Application. (2) Check the console It is successful if the following log is output to the console.   34.png

(3) Check the default page Go to localhost: 8080. Screenshot 2018-04-19 21.58.51.png

An error will occur because the default web page is not prepared.

5. Creating a web page

(1) Creating a class File → New → Select Class (2) Here, create it with the name "HelloController". Other than the name, it remains the default.    33.png

The following program is completed.

HelloController.java


package com.example.demo;

public class HelloController {

}

(3) Change to output "Hello World".

HelloController.java


package com.example.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @RequestMapping("/")
    public String index() {
        return "Hello World";
    }
}

(4) Re-execute the project and access localhost: 8080. Screenshot 2018-04-19 22.11.09.png

application.properties


server.port=8081

By rerunning the project and accessing localhost: 8081, Hello World is displayed.

Reference information (How to uninstall JDK)

(1) Confirmation of existing environment Run the following command:   $ /usr/libexec/java_home -V

Matching Java Virtual Machines (2):     1.8.0_151, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home     1.7.0_65, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_65.jdk/Contents/Home        /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home

In the above example, two JDKs are installed.

(2) Uninstall the JDK To uninstall, execute the rm command. For the path to be deleted, specify the "/ Library / Java ~" part output by the confirmation command. Also, add sudo to the head because it can only be deleted with administrator privileges. (A password will be required, so enter the administrator password.)

An example of the above is shown below.    $ sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home    Password:    $ sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.7.0_65.jdk/Contents/Home

(3) Check the environment after uninstalling Execute the following command in the same way as (1).   $ /usr/libexec/java_home -V

Unable to find any JVMs matching version "(null)".    Matching Java Virtual Machines (0):

Default Java Virtual Machines (0):

No Java runtime present, try --request to install.

Reference information (update server information)

(1) Select Eclipse → Preferences from the menu. (2) From the left panel, select a software site for which installation / update is available.   82.png

(3) Select the location where the error occurred and press the reload button. In this example, "SpringSource Update Site for Eclipse 4.7" is the location that caused the error.    83.png

Reference information (Spring project)

There are two types of Spring projects. (1) Spring Legacy Project It is used for all programs that use Spring Framework. Select this if you do not want to use the Spring Boot function. (2) Spring Starter Project It is used when creating an application that uses the Spring Boot function.

Reference information (Gradle plugin)

There are the following types of Gradle plug-ins in Eclipse. ・ Gradle IDE Plugin distributed by Nodeclipse Install from Eclipse Marketplace. ・ STS ・ Buildship The official Gradle plugin Buildship has been released on eclipse.org. Also added to Pleiades All in One.

If you have two installed, you can choose when creating a Spring project. ・ Gradle (STS) ・ Gradle (Buildship)

Reference source

https://qiita.com/cypher256/items/233795f4fc58a704ee47

Recommended Posts

Java development environment construction (Mac + Pleiades All in One Eclipse 4.7 + Spring Boot + Gradle (Buildship))
Spring Boot + Docker Java development environment construction
Java development environment (Mac, Eclipse)
[Mac] VS Code development environment construction (Java, Gradle, Node.js)
Spring Boot application development in Eclipse
◆ Spring Boot + gradle environment construction memo
[ev3 × Java] leJOS development environment construction (Eclipse on Mac OSX / bluetooth)
Spring Boot environment construction memo on mac
Play Framework 2.6 (Java) environment construction in Eclipse
Java tips-Create a Spring Boot project in Gradle
[Note] Struts2 environment construction using Gradle in Eclipse
java development environment construction
Until you start development with Spring Boot in eclipse 1
Until you start development with Spring Boot in eclipse 2
Database environment construction with Docker in Spring boot (IntellJ)
Java + Spring development environment construction with VirtualBox + Ubuntu (Xfce4)
Rails6 development environment construction [Mac]
[Spring Boot] Environment construction (macOS)
Spring Boot 2 multi-project in Gradle
JavaFX environment construction in Java 13
First Java development in Eclipse
Docker × Spring Boot environment construction
eclipse all in one installation
Web application development environment construction in Java (for inexperienced people)
Create a tomcat project using Eclipse Pleiades All in One
Create a Java and JavaScript team development environment (gradle environment construction)
Spring Boot Hello World in Eclipse
[Eclipse Java] Development environment setting memo
Java Spring environment in vs Code
Build Java development environment (for Mac)
Implement Spring Boot application in Gradle
[Java & SpringBoot] Environment Construction for Mac
Java development environment (Mac, VS Code)
Install Java development environment on Mac
JSP + Eclipse + Jetty development environment construction that even Java beginners can do
Introduction to Java development environment & Spring Boot application created with VS Code
Create Spring Boot development environment on Vagrant
[Processing x Java] Construction of development environment
Building a Lambda development environment in Eclipse
Laravel development environment construction with Docker (Mac)
Create Java Spring Boot project in IntelliJ
What is Java and Development Environment (MAC)
Build a Java development environment on Mac
Try Spring Boot 1 (Environment construction ~ Tomcat startup)
Run jooby's Eclipse development environment on Gradle
English translation of Pleiades All in One
Add spring boot and gradle to eclipse
[Environment construction] Spring Tool Suite4 installation (Mac)
Java application development environment created in VM environment
Spring Boot environment construction with Docker (January 2021 version)
[Jakarta EE 8 application development with Gradle] 1. Environment construction
JAVA + STS (Spring Tool Suite) environment construction procedure
Build Spring Boot project by environment with Gradle
Allow development in Eclipse environment using iPLAss SDK
Ruby on Rails development environment construction on M1 Mac
Points stuck in building VSCode & Java development environment
[Beginner] Install java development tool in cloud9 development environment.
LINE Bot x Java (Spring Boot) construction procedure
View the Gradle task in the Spring Boot project
Create a Spring Boot development environment with docker
[Java] Environment construction