Java Project Development Basics
Naming Convention
Java uses camelCase as the naming convention for variables, methods, and classes. But class names must be capitalized.
Package management
You can use Maven or Gradle for package (dependency) management.
Project Creation
Maven project
You can create a Maven project in the following way.
1. Maven command line
$ mvn archetype:generate \ |
2. Create a Maven project in a IDE
Project structure
Basic Maven Application
java-project/ |
src/main/java
: Java source codecom/taogen/javaproject
: Base package path. It represents the domain name of your project website.
src/main/resources/
: Static resources such as image, JavaScript, and CSS files. And configuration files.src/test/java/
: Test code.pom.xml
: Maven project configuration file.
Spring boot Web Application
java-project/ |
src/main/java
: Java source codemodules/
controller/
: HTTP request handlers.entity/
: JavaBeans, POJOs, or domain models.service/
: Business logic processing code.repository/
: Data access layer code for various persistence stores.dto/
: Data Transfer Objects, encapsulate values to carry data between processes or networks.vo/
: Value objects, a special type of objects that can hold values.
util/
: Utility classes such as StringUtil, DateUtil, IOUtil, etc.config/
: Configuration files such as Redis, MySQL data source, Security, etc.aspect/
: Spring AOP classes.annotation/
: Custom Java annotations.constant/
: Static variable classes.enums/
: Java Enum type classes.exception/
: Custom exception classes that are extended by ajava.lang.Exception
class or its subclass.filter/
: Servlet filter classes that are implementedjavax.servlet.Filter
.task/
: Scheduled tasks.
src/main/resources/
static/
: Static files such as CSS, JavaScript, image, etc.templates/
: Template files such as JSP, FreeMarker, Thymeleaf, etc.log4j2.xml
: Log configuration file.application.yml
: Spring boot configuration file.
src/test/java/
: Test code.pom.xml
: Maven project configuration file.