在IDEA中创建maven项目及后续操作

本文详细介绍了在IntelliJ IDEA中创建Maven项目的过程,包括设置源目录、配置pom.xml、处理web.xml以及使用Maven插件进行清理和部署等操作。强调了正确配置的重要性,特别是版本兼容性和错误排查。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在IDEA中创建maven项目及后续操作

https://blog.csdn.net/qq_36760873/article/details/102385125此链接为在IDEA中创建maven项目需要准备的安装配置,接下来为后续操作,下图为点击finish之后创建的maven项目截图:

在这里插入图片描述

一:创建响应文件如下图所示:

在这里插入图片描述在这里插入图片描述
在main和test中的java和resources中分别加上标记:
方式:在java和resources上右击>Mark Derectory as选择source root 和resources root呈现和上图一样的标志即可。

二:将项目对应的文件部署到maven项目中

在这里插入图片描述
三:配置pom.xml
这其实也是首要要完成的,原项目中的jar包或者是eclipse中的jar包在maven项目中,全部将配置在pom.xml中,此时它需要一个中央仓库http://repo1.maven.org/maven2在这个仓库里,你可以取到你想要的jar包。

下列是一些常用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">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.sram</groupId>
  <artifactId>maven-demo03</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>maven-demo03 Maven Webapp</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.mchange/c3p0 -->
    <dependency>
      <groupId>com.mchange</groupId>
      <artifactId>c3p0</artifactId>
      <version>0.9.5.2<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值