Maven学习笔记

来源:互联网 发布:linux shell expect 编辑:程序博客网 时间:2024/06/06 03:15
maven视频教程
http://www.icoolxue.com/album/show/45



1、添加ORACLE驱动包ojdbc,因为 oracle 的jdbc driver不在Maven的central repository中,所以不能和同其他包的方式添加 
方案:mvn install:install-file -Dfile=D:/foss/ojdbc14.jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.1.0 -Dpackaging=jar
在命令框中执行上面命令,注意ojdbc14.jar包的位置,然后在pom.xml文件中添加如下配置即可
  <dependency>
        <groupId>com.oracle</groupId>
   <artifactId>ojdbc14</artifactId>
      <version>10.2.0.1.0</version>
  </dependency>
2、在eclipse中执行maven命令,不用添加mvn,例如clean compile
3、使用maven命令部署程序并启动tomcat
方案:在pom.xml文件中添加tomcat插件,配置如下,然后使用clean tomcat6:run命令来部署启动tomcat
 <build>
  <finalName>student</finalName>
  <plugins>
   <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat6-maven-plugin</artifactId>
    <version>2.1</version>
    <configuration>
     <!-- http port -->
     <port>8888</port>
     <path>/</path>
     <uriEncoding>utf-8</uriEncoding>
     <ignorePackaging>true</ignorePackaging>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.1</version>
    <configuration>
     <!-- http port -->
     <port>8888</port>
     <path>/</path>
     <uriEncoding>utf-8</uriEncoding>
     <ignorePackaging>true</ignorePackaging>
    </configuration>
   </plugin>
  </plugins>
 </build>

4、使用Maven的mvn test执行junit测试,如果报错,可以在target/surefire-reports文件中查看具体的错误信息
5、通过右键单击pom.xml文件选择maven –> add dependency 或者是打开pom.xml文件,选择dependencies –>add 时,搜索不到依赖的jar包
解决方案:1)eclipse菜单 window-> show view –> other –> Maven
2)在打开的窗口里,右键 local repositories –> local repository ,选择 rebuild index


0 0
原创粉丝点击