intellij IDEA2021.1 Maven project使用

这篇博客指导如何在IntelliJ IDEA中新建一个Maven项目。首先从欢迎屏幕选择New Project,然后选择Maven选项。接着设置项目的SDK和(可选)archetype,输入GroupId、ArtifactId和Version等Maven坐标信息。如果使用archetype,可以进一步配置其属性。最后指定项目名称和位置,点击Finish完成创建。

Create a new Maven project

  1. If no project is currently open in IntelliJ IDEA, click New Project on the Welcome screen. Otherwise, select File | New | Project from the main menu.

  2. Select Maven from the options on the left.

  3. Specify project's SDK (JDK) or use the default one and an archetype if you want to use a predefined project template (configure your own archetype by clicking Add Archetype ).

    Click Next.

  4. On the next page of the wizard, specify the following Maven coordinates that are added to the pom.xml file:
    • GroupId- a package of a new project.

    • ArtifactId- a name of your project.

    • Version- a version of a new project. By default, this field is specified automatically.

    For more information on Maven coordinates, see Maven naming conventions.

    Click Next.
  5. If you are creating a project using a Maven archetype, IntelliJ IDEA displays the Maven settings that you can use to set the Maven home directory and Maven repositories. Also, you can check the archetype properties.

    Click Next.

  6. Specify the name and location settings.

    Click Finish.

### 查找与 IntelliJ IDEA 2021.2.2 兼容的 Maven 版本 为了确保 IntelliJ IDEAMaven 的兼容性,通常推荐使用主流稳定版的 Maven。对于 IntelliJ IDEA 2021.2.2 而言,其官方文档并未特别指出强制绑定某个特定版本的 Maven[^1]。然而,在实际开发过程中,以下几点可以帮助判断合适的 Maven 版本: #### 推荐使用Maven 版本 - **Maven 3.6.x 或更高版本** 是目前被广泛支持的标准版本范围。这些版本提供了更好的性能优化以及对现代构建工具的支持。 - 如果项目中有复杂的依赖管理需求,则可以考虑升级到最新的稳定分支(如 Maven 3.8.x),因为它们修复了许多已知问题并增强了功能。 需要注意的是,虽然理论上较新的 Maven 可以向后兼容旧版本的功能特性,但在某些特殊场景下可能会遇到不一致的行为或者插件适配上的差异。因此建议先尝试设置为 `Apache Maven 3.6.3` 并验证环境配置是否正常工作后再决定进一步调整具体数值大小。 以下是针对该IDEA版本的一个典型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> <!-- Other configurations --> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> <!-- Dependency Management --> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.2.4.RELEASE</version> </dependency> </dependencies> </dependencyManagement> </project> ``` 此代码段展示了基本的POM结构,并通过 `<dependencyManagement>` 部分锁定了 Spring 组件的具体版本号来避免潜在冲突情况发生[^3]。 另外值得注意的一点是关于ANTLR相关处理时也需要引入相应运行库作为依赖项以便顺利完成解析任务操作[^2]: ```xml <dependency> <groupId>org.antlr</groupId> <artifactId>antlr4-runtime</artifactId> <version>4.9.2</version> </dependency> ``` 最后提醒一下, 若发现存在多个相互矛盾定义可能导致加载失败等问题时候可借助于"Maven Helper"插件来进行排查分析解决办法[^3].
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值