2、maven在 Eclipese 上运行

来源:互联网 发布:网络舆情公司排名 编辑:程序博客网 时间:2024/05/24 01:37

目录

  • 目录
  • 1jar 包的作用范围
  • 2maven 项目测试
    • 2-1调整 jdk 版本整个项目编码

1、jar 包的作用范围

这里写图片描述

  • 对应代码:
    这里写图片描述

这里写图片描述
这里写图片描述

  • 为什么要弄作用域呢?
  • 因为比如:provided,只在不运行的时候起作用,避免了 servlet-api 和 tomcat 中的冲突。

2、maven 项目测试

2-1、调整 jdk 版本&整个项目编码

这里写图片描述

  • 如何调?,以下代码放到 pom.xml
  <!-- 调整jdk版本及编码 -->  <build>        <plugins>            <plugin>                <groupId>org.apache.maven.plugins</groupId>                <artifactId>maven-compiler-plugin</artifactId>                <configuration>                    <source>1.7</source>                    <target>1.7</target>                    <encoding>UTF-8</encoding>                </configuration>            </plugin>        </plugins>    </build>
  • 右键项目 —-> run as —-> maven build —-> tomcat:run
    这里写图片描述
    这里写图片描述

  • 让本来jdk1.5 —-> 1.7,还需要 update maven
    这里写图片描述

  • 然后运行成功了。
    这里写图片描述

  • 测试访问成功
    这里写图片描述
1 1
原创粉丝点击