20秒 教你maven2的pom文件的依赖包怎么写

所有Maven 库 需要的包 及 pom.xml 中 groupId artifactId version 都可在这个网上收到。

例如:需要 通过 maven 在项目 中 添加 geronimo-kernel 的包,但不知道 maven 中的 pom 文件的 groupId artifactId version 是什么?这种情况下就可到 http://grepcode.com/ 搜索。

步骤:
1:框中输入: geronimo-kernel

2:在左侧 All Repositories 列表中,选中 Maven-Central 项

3:右侧依次 出现 org.apache.geronimo.framework / geronimo-kernel
3.0-M1 2.2.1 2.2 2.1.7 2.1.6 2.1.5


4:pom文件中输入:

<dependency>
<groupId>org.apache.geronimo.framework</groupId>
<artifactId>geronimo-kernel</artifactId>
<version>2.2</version>
</dependency>


[size=large][b]http://grepcode.com/[/b][/size]
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Maven POM (Project Object Model) 文件Maven 项目的核心配置文件,其中含了项目中所有的依赖、插件、构建配置等信息。在 Maven过程中,POM 文件的正确配置非常重要。以下是一个基本的 Maven POM 文件配置示例: ```xml <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.example</groupId> <artifactId>my-app</artifactId> <version>1.0-SNAPSHOT</version> <!-- 依赖声明 --> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies> <!-- 插件声明 --> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.1.2</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>com.example.App</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> </project> ``` 在上述 POM 文件中,`<groupId>`、`<artifactId>` 和 `<version>` 标签定义了项目的基本信息。`<dependencies>` 标签用于声明项目依赖的其他库,`<build>` 标签下的 `<plugins>` 标签用于声明项目构建时所需要的插件。 在打过程中,可以使用以下命令: ``` mvn package ``` 该命令会在当前项目根目录下生成一个名为 `my-app-1.0-SNAPSHOT.jar` 的可执行 JAR 文件,其中含了项目的所有依赖和代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值