• Maven的简单使用


    Maven使用

    在官网下载maven

    http://maven.apache.org/download.cgi

     

    解压到D盘(位置随便)

    配置环境变量

     

    打开dos窗口,检测是否成功,出现如下画面表示配置成功

     

    打开配置文件setting.xml配置仓库镜像

     

    找到mirrors标签,加入以下内容,这是阿里的maven仓库

    <mirror>

    <!--This sends everything else to /public -->

    <id>nexus-aliyun</id>

    <mirrorOf>*</mirrorOf>

    <name>Nexus aliyun</name>

    <url>http://maven.aliyun.com/nexus/content/groups/public</url>

    </mirror>

    如下:

     

    打开eclipse

    点击windows-->Preferences

     

    在搜索框搜索maven-->User Setting-->Browse,选中settings.xml打开,然后点击Reindex进行刷新仓库位置

     

    到此maven的配置结束

    Maven工程创建

    点击File--->New--->Other

     

    搜索maven

     

     

     

    起初报错,是因为缺少web.xml文件,创建WEB-INF文件夹,添加web.xml文件

     

    网上搜的最新pom.xml,直接添加到pom文件中即可

    <properties>

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

            <junit.version>4.9</junit.version>

            <spring.version>4.3.10.RELEASE</spring.version>

            <mybatis.version>3.4.4</mybatis.version>

            <mybatis.spring.version>1.3.1</mybatis.spring.version>

            <commons-dbcp.version>1.4</commons-dbcp.version>

            <jstl.version>1.2</jstl.version>

            <log4j.version>1.2.17</log4j.version>

            <fastjson.version>1.2.35</fastjson.version>

            <slf4j.version>1.7.25</slf4j.version>

            <jackson.version>1.9.13</jackson.version>

            <commons-fileupload.version>1.3.3</commons-fileupload.version>

            <commons-io.version>2.5</commons-io.version>

            <commons-codec.version>1.10</commons-codec.version>

            <aspectjweaver.version>1.8.10</aspectjweaver.version>

    </properties>

    <dependencies>

                <!-- Junit测试 -->

                <dependency>

                    <groupId>junit</groupId>

                    <artifactId>junit</artifactId>

                    <version>${junit.version}</version>

                    <scope>test</scope>

                </dependency>

     

                <!-- springcoreweboxmtxjdbcwebmvcaopcontexttest -->

                <dependency>

                    <groupId>org.springframework</groupId>

                    <artifactId>spring-core</artifactId>

                    <version>${spring.version}</version>

                </dependency>

                <dependency>

                    <groupId>org.springframework</groupId>

                    <artifactId>spring-web</artifactId>

                    <version>${spring.version}</version>

                </dependency>

                <dependency>

                    <groupId>org.springframework</groupId>

                    <artifactId>spring-oxm</artifactId>

                    <version>${spring.version}</version>

                </dependency>

                <dependency>

                    <groupId>org.springframework</groupId>

                    <artifactId>spring-tx</artifactId>

                    <version>${spring.version}</version>

                </dependency>

                <dependency>

                    <groupId>org.springframework</groupId>

                    <artifactId>spring-jdbc</artifactId>

                    <version>${spring.version}</version>

                </dependency>

                <dependency>

                    <groupId>org.springframework</groupId>

                    <artifactId>spring-webmvc</artifactId>

                    <version>${spring.version}</version>

                </dependency>

                <dependency>

                    <groupId>org.springframework</groupId>

                    <artifactId>spring-aop</artifactId>

                    <version>${spring.version}</version>

                </dependency>

     

                <dependency>

                    <groupId>org.springframework</groupId>

                    <artifactId>spring-context-support</artifactId>

                    <version>${spring.version}</version>

                </dependency>

                <dependency>

                    <groupId>org.springframework</groupId>

                    <artifactId>spring-test</artifactId>

                    <version>${spring.version}</version>

                </dependency>

                <!-- mybatis核心包 -->

                <dependency>

                    <groupId>org.mybatis</groupId>

                    <artifactId>mybatis</artifactId>

                    <version>${mybatis.version}</version>

                </dependency>

                <!-- mybatis/spring-->

                <dependency>

                    <groupId>org.mybatis</groupId>

                    <artifactId>mybatis-spring</artifactId>

                    <version>${mybatis.spring.version}</version>

                </dependency>

     

                <!-- 导入Mysql数据库链接jar-->

                <dependency>

                    <groupId>mysql</groupId>

                    <artifactId>mysql-connector-java</artifactId>

                    <version>6.0.6</version>

                </dependency>

     

                <!-- 导入dbcpjar包,用来在applicationContext.xml中配置数据库 -->

                <dependency>

                    <groupId>commons-dbcp</groupId>

                    <artifactId>commons-dbcp</artifactId>

                    <version>${commons-dbcp.version}</version>

                </dependency>

                <!-- JSTL标签类 -->

                <dependency>

                    <groupId>jstl</groupId>

                    <artifactId>jstl</artifactId>

                    <version>${jstl.version}</version>

                </dependency>

                <!-- 日志文件管理包 -->

                <dependency>

                    <groupId>log4j</groupId>

                    <artifactId>log4j</artifactId>

                    <version>${log4j.version}</version>

                </dependency>

     

                <!-- 格式化对象,方便输出日志 -->

                <dependency>

                    <groupId>com.alibaba</groupId>

                    <artifactId>fastjson</artifactId>

                    <version>${fastjson.version}</version>

                </dependency>

     

     

                <dependency>

                    <groupId>org.slf4j</groupId>

                    <artifactId>slf4j-api</artifactId>

                    <version>${slf4j.version}</version>

                </dependency>

     

                <dependency>

                    <groupId>org.slf4j</groupId>

                    <artifactId>slf4j-log4j12</artifactId>

                    <version>${slf4j.version}</version>

                </dependency>

                <!-- jsonbean之间相互转换 -->

                <dependency>

                    <groupId>org.codehaus.jackson</groupId>

                    <artifactId>jackson-core-asl</artifactId>

                    <version>${jackson.version}</version>

                </dependency>

                <dependency>

                    <groupId>org.codehaus.jackson</groupId>

                    <artifactId>jackson-mapper-asl</artifactId>

                    <version>${jackson.version}</version>

                </dependency>

                <!-- 上传组件包 -->

                <dependency>

                    <groupId>commons-fileupload</groupId>

                    <artifactId>commons-fileupload</artifactId>

                    <version>${commons-fileupload.version}</version>

                </dependency>

                <dependency>

                    <groupId>commons-io</groupId>

                    <artifactId>commons-io</artifactId>

                    <version>${commons-io.version}</version>

                </dependency>

                <dependency>

                    <groupId>commons-codec</groupId>

                    <artifactId>commons-codec</artifactId>

                    <version>${commons-codec.version}</version>

                </dependency>

     

     

                <dependency>

                    <groupId>org.aspectj</groupId>

                    <artifactId>aspectjweaver</artifactId>

                    <version>${aspectjweaver.version}</version>

                </dependency>

     

                <dependency>

                    <groupId>javax.servlet</groupId>

                    <artifactId>javax.servlet-api</artifactId>

                    <version>4.0.0-b07</version>

                    <scope>provided</scope>

                </dependency>

    </dependencies>

    <!-- 排除项目中的依赖冲突时使用。 -->

    <build>

            <plugins>

                <plugin>

                    <groupId>org.apache.maven.plugins</groupId>

                    <artifactId>maven-compiler-plugin</artifactId>

                    <version>2.3.2</version>

                    <configuration>

                    <source>1.8</source>

                    <target>1.8</target>

                    </configuration>

                </plugin>

            </plugins>

    </build>

    Pom文件详解可参照

    http://www.cnblogs.com/sharpest/p/5969566.html

  • 相关阅读:
    [总结]2020年8月 OI学习/刷题记录
    [总结]2020年7月 OI学习/刷题记录
    [总结]2020年6月 OI学习/刷题记录
    [总结]2020年5月 OI学习/刷题记录
    [Luogu P6474][NOI Online #2 入门组]荆轲刺秦王 题解(BFS)
    [总结]2020年4月 OI学习/刷题记录
    [总结]2020年3月 OI学习/刷题记录
    [Luogu P6059]纯粹容器 senpai
    [Luogu P6044]「ACOI2020」惊吓路径
    ubuntu下查看(改变)本地端口开放情况,开启和关闭防火墙
  • 原文地址:https://www.cnblogs.com/java-spring/p/7791790.html
Copyright © 2020-2023  润新知