惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
The GitHub Blog
The GitHub Blog
C
Check Point Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
F
Full Disclosure
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
G
GRAHAM CLULEY
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
博客园 - 司徒正美
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Cisco Talos Blog
Cisco Talos Blog
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
V
V2EX - 技术
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
罗磊的独立博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
O
OpenAI News
Jina AI
Jina AI
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
I
InfoQ
D
Docker
P
Palo Alto Networks Blog
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
博客园 - Franky
B
Blog
Scott Helme
Scott Helme
博客园 - 叶小钗
D
DataBreaches.Net

博客园 - 滴水冰寒

阿里云linux--常用命令 electron桌面应用 wepack打包时出错不压缩代码及使用es7(async await)新语法问题 npm install 时发生错误 create-react-app 后使用babel/polyfill webpack3.x--react,jsx多页配置 webpack--打包scss webpack--打包和压缩css react--2.react-redux react--1.创建项目 百度智能语音引用1 vscode和gitee的使用 vue--1.环境搭建及创建项目 Python内置的服务器的使用 ionic3问题记录 ionic3自定义android原生插件 maven学习--1.安装与配置 mybatis学习笔记1.零碎记录 mysql学习--1.事务
maven学习--1.项目结构及简单使用
滴水冰寒 · 2018-04-04 · via 博客园 - 滴水冰寒

1.项目目录结构

MavenProjectRoot(项目根目录)
   |----src
   |     |----main
   |     |         |----java ——存放项目的.java文件
   |     |         |----resources ——存放项目资源文件,如spring, hibernate配置文件
   |     |----test
   |     |         |----java ——存放所有测试.java文件,如JUnit测试类
   |     |         |----resources ——存放项目资源文件,如spring, hibernate配置文件
   |----target ——项目输出位置
   |----pom.xml ----用于标识该项目是一个Maven项目

2.手动创建Maven项目,使用Maven编译

2.1创建项目根文件夹,例如E:\Maven01

2.2在Maven01文件夹中创建“pom.xml”文件(pom.xml是maven项目的配置文件,必须)

pom.xml文件中的内容如下:

<?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">
    <!--所有的Maven项目都必须配置这四个配置项-->
    <modelVersion>4.0.0</modelVersion>
    <!--groupId指的是项目名的项目组,默认就是包名-->
    <groupId>me.gacl.maven</groupId>
    <!--artifactId指的是项目中的某一个模块,默认命名方式是"项目名-模块名"-->
    <artifactId>Hello</artifactId>
    <!--version指的是版本,这里使用的是Maven的快照版本-->
    <version>0.0.1-SNAPSHOT</version>
    
    <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>
    
    <!--添加依赖的jar包-->
     <dependencies>
         <!--项目要使用到junit的jar包,所以在这里添加junit的jar包的依赖-->
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <version>4.9</version>
             <scope>test</scope>
         </dependency>        
         
     </dependencies>
    
     <!-- 
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <encoding>utf8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
     -->
</project>

2.3编写Java类文件,Maven项目规定,所有的*.java文件必须放在src目录下的main目录下的java目录中,在Maven01项目根目录中创建一个src目录,然后在src目录中创建main目录,在main目录中再创建java文件夹,路径如下:

E:\Maven01\src\main\java\me\gacl\maven\Hello.java

package me.gacl.maven;

public class Hello{
    public String sayHello(String name){
        return "Hello打扰了" + name + "!";
        
    }
    
}