maven查看了依赖项的错误目录

时间:2016-07-05 10:27:41

标签: maven

我有以下孩子pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
      <groupId>runtime_shared</groupId>
      <artifactId>runtime_shared.master</artifactId>
      <relativePath>../pom.xml</relativePath>
      <version>1.0.0-SNAPSHOT</version>
   </parent>
   <groupId>runtime_shared</groupId>
   <artifactId>javax.vecmath</artifactId>
   <name>javax.vecmath</name>
   <version>1.0.0.qualifier</version>
   <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.3.1</version>
            <executions>
                <execution>
                    <id>vecmath</id>
                    <phase>install</phase>
                    <goals>
                        <goal>install-file</goal>
                    </goals>
                    <configuration>
                        <file>${basedir}/vecmath.jar</file>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>${project.artifactId}</artifactId>
                        <version>${project.version}</version>
                        <packaging>jar</packaging>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
</project>

我希望它将javax.vecmath安装到我的本地存储库(.m2/repository)。稍后我在我的父pom.xml中指定了这个:

   <dependency>
         <groupId>runtime_shared</groupId>
         <artifactId>javax.vecmath</artifactId>
         <version>1.0.0.qualifier</version>
   </dependency>

但是,当我mvn install -X时,我会看到maven寻找完全不同的路径,例如:

[DEBUG]  /home/usr/workspace_runtime/runtime_shared/javax.vecmath/target/javax.vecmath-1.0.0.qualifier.jar

显然会出错。是因为某些环境变量设置错误,还是因为<file>${basedir}/vecmath.jar</file>标记,其中${basedir}以其他方式指向其他地方?我也尝试使用${project.basedir},但它也没有用。

为了给出更清晰的图片,这是另一种情况:

[DEBUG]  /home/usr/.m2/repository/x/org.apache.felix.main/1.0.0/org.apache.felix.main-1.0.0.jar
[DEBUG]  /home/usr/.m2/repository/x/org.apache.felix.gogo/0.10.0/org.apache.felix.gogo-0.10.0.jar
[DEBUG]  /home/usr/workspace_runtime/x/com.google.protobuf/target/com.google.protobuf-2.5.0.jar

如果您注意到,前两个项目的目录是正确的。但是,最后一个,不知何故被查看在错误的目录下。因此:

package com.google.protobuf does not exist

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

如果您使用以下命令声明Maven项目:

import React from 'react';
import { Router , Route, Link , hashHistory } from 'react-router';


class App extends React.Component {
   render() {
      return (
       <div className="container-fluid">
          <div className="row">
             <div className="col-md-10 col-md-offset-1">
                <Content/>
              </div>
          </div>
       </div>
    );
  }}


class Content extends React.Component{
    render(){
        return(
           <section  id="content-wrapper" className="container">
                <div className="row-fluid">
                    <div className="row">
                     <div className="col-md-6 col-md-offset-3">
                        <div className="col-lg-4">
                          <Link to="/survey"><img className="img-circle" src="assets/images/survey.png" alt="Generic placeholder image" /></Link>

                        </div>
                        <div className="col-lg-4">
                         <Link to="/media"> <img className="img-circle" src="assets/images/media.png" alt="Generic placeholder image"/></Link>


                        </div>
                        <div className="col-lg-4">
                          <Link to="/paticipants"><img className="img-circle" src="assets/images/part.png" alt="Generic placeholder image" /></Link>

                        </div>
                      </div>
                    </div>
                    <div className="row">
                     <div className="col-md-6 col-md-offset-3">
                        <div className="col-lg-4">
                          <Link to="/themes"><img className="img-circle" src="assets/images/themes.png" alt="Generic placeholder image"/></Link>

                        </div>
                        <div className="col-lg-4">
                          <Link to="/tools"><img className="img-circle" src="assets/images/tools.png" alt="Generic placeholder image"/></Link>


                        </div>
                        <div className="col-lg-4">
                          <Link to="/questionaire"><img className="img-circle" src="assets/images/quest.png" alt="Generic placeholder image"  /></Link>

                        </div>
                      </div>
                    </div>
                </div>
         </section>
        );
   }
}

export default App;

这意味着这是你的项目,Maven:

  • 您的源(默认情况下在<groupId>runtime_shared</groupId> <artifactId>javax.vecmath</artifactId> <version>1.0.0.qualifier</version> 中)创建项目jar目录中的工件/target
  • 如果至少调用了src/main/java/...packages...,则将其安装到您当地的Maven仓库(默认值为~/.m2/repository)(请参阅Maven / Introduction to the Build Lifecyclethis answer
  • 如果调用mvn install,则
  • 将其部署到remote Maven repo

它并不意味着将第三方工件(例如javax.vecmath:vecmath)添加到您的任何存储库。

请参阅once againthe answer to your question a few days ago的第1和第2点,了解如何将第三方工件放入您的存储库,无论是本地还是远程。