- Java 9 Programming Blueprints
- Jason Lee
- 351字
- 2021-07-02 18:56:31
Getting started
This application, while conceptually fairly simple, is a bit more complex than what we looked at in the last chapter, in that we will have both, a command line and a graphical interface. The experienced programmer is likely to immediately see the need to share the code between these two interfaces, as DRY (Don't Repeat Yourself) is one of the many hallmarks of a well-designed system. To facilitate this sharing of code, then, we will want to introduce a third module, which provides a library that can be consumed by the other two projects. We will call these modules lib, cli, and gui. Our first step in setting up the project is to create the various Maven POM files to describe the project's structure. The parent POM will look something like this:
<?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.steeplesoft.dupefind</groupId> <artifactId>dupefind-master</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <modules> <module>lib</module> <module>cli</module> <module>gui</module> </modules> <name>Duplicate Finder - Master</name> </project>
This is a fairly typical POM file. We will start by identifying the project's parent that lets us inherit a number of settings, dependencies, and so on, and avoid having to repeat them in this project. Next, we will define the Maven coordinates for the project. Note that we don't define a version for this project, allowing the parent's version to cascade down. This will allow us to increase the version as needed in one place, and update all of the subprojects implicitly.
The last interesting part of this POM, for those who haven't seen a multi-module project before, is the modules section. The only thing to note here, for those who are new to this, is that each module element refers to a directory name, which is a direct child of the current directory, and should be declared in the order in which they are needed. In our case, the CLI and GUI both depend on the library, so lib goes first. Next, we'll need to create the POM files for each module. Each of these are typical POMs of type jar, so there's no need to include them here. There will be varying dependencies in each, but we'll cover those as the need arises.
- Vue.js設計與實現
- UML+OOPC嵌入式C語言開發精講
- C語言程序設計學習指導與習題解答
- Python忍者秘籍
- MySQL從入門到精通(軟件開發視頻大講堂)
- Python+Tableau數據可視化之美
- OpenCV with Python By Example
- 響應式Web設計:HTML5和CSS3實戰(第2版)
- Qlik Sense? Cookbook
- Learning iOS Security
- PHP與MySQL權威指南
- Mastering HTML5 Forms
- Getting Started with Electronic Projects
- Developing Java Applications with Spring and Spring Boot
- 青少年Python趣味編程