Maven环境的搭建与idea配置

Maven环境的搭建与idea配置

Maven 下载: http://maven.apache.org/download.cgi

Maven 中央仓库地址:http://search.maven.org 

配置maven环境变量

M2_HOME:D:\workspace\maven\apache-maven-3.0.5

Path:;%M2_HOME%/bin;

检查是否成功,打开CMD

Mvn -v

mvn install 会将项目生成的构件安装到本地Maven仓库 

mvn deploy 用来将项目生成的构件分发到远程Maven仓库 

D:\>mvn archetype:generate:在D:盘构建maven标准项目目录结构

2、settings.xml文件配置

2.0修改本地仓库位置

M2_home目录下 conf/settings.xml

<localRepository>D:/workspace/maven/stone</localRepository>


2.1如何配置远程仓库(私服): (nexus-2.0.4-1-bundle) 

<profiles>
    <profile>
        <id>nexus</id>
        <repositories><!--配置远程仓库-->
            <repository>
                <id>nexus</id>
                <name>Central Repository</name>
                <url>http://127.0.0.1/nexus/content/groups/public</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled><!---->
                </snapshots>
            </repository>
        </repositories>
        <pluginRepositories><!--配置Maven从什么地方下载插件构件-->
            <pluginRepository>
                <id>nexus</id>
                <name>Central Repository</name>
                <url>http://127.0.0.1/nexus/content/groups/public</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>
</profiles>

<activeProfiles><!--激活 远程仓库-->
        <activeProfile>nexus</activeProfile>
</activeProfiles>


-------------------------------------------------------------------------------------------------

2.2还可以配置仓库的镜像下载

<mirrors>
<mirror><!--配置镜像-->
    <id>nexus</id>
    <mirrorOf>*</mirrorOf>
    <url>http://127.0.0.1/nexus/content/groups/public</url>
</mirror>
</mirrors>

3、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>xu.feifei</groupId>
    <artifactId>feifei</artifactId>
    <packaging>war</packaging>
    <version>1.0</version>

    <dependencies>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20090211</version>
        </dependency>

    </dependencies>

    <build>
        <finalName>feifei</finalName>
    </build>
    
</project>

二、IDEA的搭建Maven相关配置

.


maven项目的包结构


设置maven自动导包



























  • 5
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
使用Maven搭建SSM框架的步骤如下: 1. 首先,确保你已经安装了Java和Maven,并且环境变量已经配置好。 2. 创建一个Maven项目: ``` mvn archetype:generate -DgroupId=com.example -DartifactId=myproject -DarchetypeArtifactId=maven-archetype-webapp ``` 3. 进入项目目录: ``` cd myproject ``` 4. 在`pom.xml`文件中添加SSM依赖: ```xml <dependencies> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.3.13.RELEASE</version> </dependency> <!-- Spring MVC --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.3.13.RELEASE</version> </dependency> <!-- MyBatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.7</version> </dependency> <!-- 数据库驱动 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.26</version> </dependency> </dependencies> ``` 5. 创建Spring配置文件`applicationContext.xml`,配置Spring和MyBatis相关的内容。 6. 创建MyBatis的映射文件,定义数据库表的映射关系。 7. 创建Controller、Service和Dao层的Java类,编写业务逻辑和数据库操作。 8. 编译项目: ``` mvn compile ``` 9. 打包项目: ``` mvn package ``` 10. 部署项目: 将生成的war包部署到Web容器(如Tomcat)中即可。 这样,你就使用Maven成功搭建了一个SSM框架的项目。在实际开发中,你可能还需要配置数据库连接、日志等相关内容,具体根据项目需求进行配置和开发。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值