maven在eclipse中的配置(步骤)

1 篇文章 0 订阅
1 篇文章 0 订阅
一、 Maven zip包解压后,path的路径配置
1>找到解压包中的bin目录,复制bin的全路径;
2>在path路径中粘贴加分号(“;”);
3>在dos窗口命令中使用 mvn --version; 查看配置是否成功!(配置完path后,记得重新打开dos窗口<如果原来dos窗口已打开>);


二、 Maven中settings.xml的配置
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
       
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                       

                xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">


      <localRepository>/Users/apple/.m2_web/repository</localRepository>


1>打开Maven 解压包中的apache_maven_3.3.9\conf\settings.xml 文件,并修改settings.xml中的<localRepository>节点的内容,例如可改为:( e:\\m2\repository),
2>创建在settings.xml中修改好的对应磁盘下的文件夹m2
3>将apache_maven_3.3.9\conf 下已修改的settings.xml文件复制到文件夹m2下,并将repository.zip解压包的解压文件中的repository复制到m2目录下;
4>准备工作基本完成;

三、 Eclipse中的具体配置

1>Windows ---> preferences --> Maven --> Installations --> Add --> Installation home:Directory(选择解压成功后的文件夹apache_maven_3.3.9)--> finish -->Apply
2>Windows ---> preferences --> Maven --> User Settings --> Global Settings :Browse(apache_maven_3.3.9\apache_maven_3.3.9\conf\settings.xml);
        --> User Settings:Browse(m2\settings.xml);
      --> Update Settings
      --> Apply
      --> ok
3>在Eclipse中新建项目及其相关设置
 
 (1) File --> New ---> Other.. --> Maven --> Maven Project --> next --> next --> 选择org.apache.maven.archetypes maven-archetype-webapp 1.0 

 --> next --> Group Id:自写   Artifact Id:项目名 --> finish

(2) 删除 src/main/webapp 

(3) 右击项目名 --> properties --> Maven --> Project Facets  --> 去掉Dynamic Web Module对勾 (版本修改至3.0)
            --> Java (版本修改至1.8)
    --> apply
            --> Runtimes(选择apache Tomcat 7.0 版本)
            --> apply
    --> 打上Dynamic Web Module对勾
    --> 点击下方的configuration 配置链接
    --> 修改webcontent 为 src/main/webapp ;
    --> apply -->ok
4>将missing 的 src/main/java 通过右击项目-->build path -->config -->resource  移除missing的src/main/java 
-->然后回到项目--> 右击项目 -->new-->resource folder(src/main/java)
-->ok


5>配置pom.xml

复制sh_pom.xml中配置hibernate和struts的包的属性于pom.xml(Maven会自动添加并配置相关jar包)


6>添加mysql的jar包


注意:一般:在src/main/resource中放置资源文件(hibernate.cfg.xml;struts.xml;log4j.properties等);
   在src/main/java中写java类;

特别注意:

1、apache_maven_3.3.9.zip(maven安装压缩包的下载)

2、repository.zip(maven配置所需repository压缩包的下载)

3、上边提到的sh_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/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.qfxa</groupId>
	<artifactId>sh</artifactId>
	<packaging>war</packaging>
	<version>0.0.1-SNAPSHOT</version>
	<name>sh Maven Webapp</name>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>


		<hibernate.version>5.2.3.Final</hibernate.version>
		<struts2.version>2.5.5</struts2.version>
	</properties>

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


		<!--<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-core</artifactId>
			<version>2.5</version>
		</dependency>-->


		<!-- hibernate -->
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<version>${hibernate.version}</version>
		</dependency>


		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-ehcache</artifactId>
			<version>${hibernate.version}</version>
		</dependency>


		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-c3p0</artifactId>
			<version>${hibernate.version}</version>
		</dependency>


		<!-- struts2 -->
		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-core</artifactId>
			<version>${struts2.version}</version>


			<exclusions>
				<exclusion>
					<!-- Hibernate已经还有该包的依赖 -->
					<artifactId>javassist</artifactId>
					<groupId>javassist</groupId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-convention-plugin</artifactId>
			<version>${struts2.version}</version>
		</dependency>

	</dependencies>
	<build>
		<finalName>sh</finalName>
	</build>
</project>
							         





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值