官术网_书友最值得收藏!

The basics of Eclipse and Maven

Eclipse is an IDE for multiple programming languages, such as Java, C++, and Python. Eclipse contains different perspectives for your needs. A perspective is a set of views and editors in the Eclipse Workbench. The following screenshot shows common perspectives for Java development:

On the left side, we have Project Explorer, where we can see our project structure and resources. Project Explorer is also used to open files by double-clicking on them. The files will be opened in the editor, that is located in the middle of the workbench. The Console view can be found in the lower section of the workbench. The Console view is really important because it shows application logging messages.

You can get the Spring Tool Suite (STS) for Eclipse if you want, but we are not going to use it in this book because the plain Eclipse installation is enough for our purposes. STS is a set of plugins that makes Spring application development easier (https://spring.io/tools).

Apache Maven is a software project management tool. The basis of Maven is the project object model (pom). Maven makes the software development process easier and it also unifies the development process. You can also use another project management tool called Gradle with Spring Boot, but in this book, we will focus on using Maven.

The pom is a pom.xml file that contains basic information about the project. There are also all the dependencies that Maven should download to be able to build the project.

Basic information about the project can be found at the beginning of the pom.xml file, which defines, for example, the version of the application, packaging format, and so on.

The minimum version of the pom.xml file should contain the project root, modelVersion, groupId, artifactId, and version.

Dependencies are defined inside the dependencies section, as follows:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.packt</groupId>
<artifactId>cardatabase</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>cardatabase</name>
<description>Demo project for Spring Boot</description>

  <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

Maven is normally used from the command line. Eclipse contains embedded Maven, and that handles all the Maven operations we need. Therefore, we are not focusing on Maven command-line usage here. The most important thing is to understand the structure of the pom.xml file and how to add new dependencies to it.

主站蜘蛛池模板: 密云县| 大邑县| 天祝| 宁远县| 江城| 修武县| 延安市| 兰坪| 望城县| 高陵县| 河津市| 上栗县| 德阳市| 疏附县| 南涧| 丰镇市| 泰州市| 胶州市| 永新县| 涞源县| 榆树市| 黑河市| 泽州县| 和田县| 罗甸县| 兴仁县| 宁阳县| 泉州市| 和顺县| 贺兰县| 新化县| 保定市| 蒙自县| 公安县| 甘德县| 公安县| 繁峙县| 宁乡县| 新宾| 盐城市| 蒙山县|