maven工程pom文件老是报错

scarred1992
  • 6

本人mac端,从svn上下载了一个maven工程
在eclipse上使用maven install 时候老是失败
本地仓库已经指定好,但是还是显示无法获取指定的jar包
信息如下

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building caf-template-adminlte 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] Could not transfer metadata com.cpic.caf:caf-template-service:1.0-SNAPSHOT/maven-metadata.xml from/to caf_repositories (/Users/sml/Documents/repository): Cannot access /Users/sml/Documents/repository with type default using the available connector factories: AetherRepositoryConnectorFactory, BasicRepositoryConnectorFactory
[WARNING] Failure to transfer com.cpic.caf:caf-template-service:1.0-SNAPSHOT/maven-metadata.xml from /Users/sml/Documents/repository was cached in the local repository, resolution will not be reattempted until the update interval of caf_repositories has elapsed or updates are forced. Original error: Could not transfer metadata com.cpic.caf:caf-template-service:1.0-SNAPSHOT/maven-metadata.xml from/to caf_repositories (/Users/sml/Documents/repository): Cannot access /Users/sml/Documents/repository with type default using the available connector factories: AetherRepositoryConnectorFactory, BasicRepositoryConnectorFactory
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.530 s
[INFO] Finished at: 2017-11-09T15:15:33+08:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project caf-template-adminlte: Could not resolve dependencies for project com.cpic:caf-template-adminlte:war:1.0-SNAPSHOT: Failed to collect dependencies at com.oracle.jdbc.driver:ojdbc6:jar:11g: Failed to read artifact descriptor for com.oracle.jdbc.driver:ojdbc6:jar:11g: Could not transfer artifact com.oracle.jdbc.driver:ojdbc6:pom:11g from/to caf_repositories (/Users/sml/Documents/repository): Cannot access /Users/sml/Documents/repository with type default using the available connector factories: AetherRepositoryConnectorFactory, BasicRepositoryConnectorFactory -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

pom文件如下

<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.cpic</groupId>
    <artifactId>caf-template-adminlte</artifactId>
    <name>caf-template-adminlte</name>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <java-version>1.7</java-version>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!--  使用mysql数据库时 开启
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.34</version>
        </dependency> -->
        <dependency>
            <groupId>com.oracle.jdbc.driver</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11g</version>
        </dependency>
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-solrj</artifactId>
            <version>4.7.2</version>
        </dependency>
        <dependency>
            <groupId>com.cpic.caf</groupId>
            <artifactId>caf-template-service</artifactId>
            <version>1.0-SNAPSHOT</version>
            <exclusions>
                <exclusion>
                    <groupId>com.oracle.jdbc.driver</groupId>
                    <artifactId>ojdbc6</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>3.2.8.RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.27</version>
        </dependency>
        
        
        <!-- mybatis框架相关依赖包 -->  
        <dependency>  
            <groupId>org.mybatis</groupId>  
            <artifactId>mybatis</artifactId>  
            <version>3.2.7</version>  
        </dependency>  
        <dependency>  
            <groupId>org.mybatis</groupId>  
            <artifactId>mybatis-spring</artifactId>  
            <version>1.2.2</version>  
        </dependency>  
        
        <!-- 用于集成xxl-job的执行器
        <dependency>
            <groupId>com.xuxueli</groupId>
            <artifactId>xxl-job-core</artifactId>
            <version>1.4.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>slf4j-log4j12</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>javax.servlet</artifactId>
                    <groupId>*</groupId>
                </exclusion>
            </exclusions>
        </dependency> -->
    </dependencies>


    <profiles>
        <profile>
               <id>localDev</id>
               <activation>
                   <!-- 默认为该环境  -->
                   <activeByDefault>true</activeByDefault>
                   <property>
                       <name>env</name>
                       <value>localDev</value>
                   </property>
               </activation>
               <build>
                   <!-- 在本地打包构建时的文件路径 -->
                   <resources>
                    <resource>
                        <directory>src/main/java</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                    </resource>
                    <resource>
                        <directory>src/main/resources</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                    </resource>
                    <resource>
                        <directory>src/main/localDevResources</directory>
                    </resource>
                </resources>
               </build>
        </profile>
        <profile>
               <id>CI</id>
               <activation>                   
                   <property>
                       <name>env</name>
                       <value>CI</value>
                   </property>
               </activation>
               <build>
                   <!-- 在CI环境打包构建时的文件路径 -->
                   <resources>
                    <resource>
                        <directory>src/main/java</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                    </resource>
                    <resource>
                        <directory>src/main/resources</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                    </resource>
                    <resource>
                        <directory>src/main/CIResources</directory>
                    </resource>
                </resources>
               </build>
        </profile>
        <profile>
               <id>Server</id>
               <activation>                   
                   <property>
                       <name>env</name>
                       <value>server</value>
                   </property>
               </activation>
               <build>
                   <!-- 在生产环境打包构建时的文件路径 -->
                   <resources>
                    <resource>
                        <directory>src/main/java</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                    </resource>
                    <resource>
                        <directory>src/main/resources</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                    </resource>
                    <resource>
                        <directory>src/main/ServerResources</directory>
                    </resource>
                </resources>
               </build>
        </profile>
    </profiles>
    
    <repositories>
        <repository>
            <id>caf_repositories</id>
            <url>/Users/sml/Documents/repository</url>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>interval:5</updatePolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>cpic-nexus</id>
            <url>/Users/sml/Documents/repository</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
    
   </project>
回复
阅读 6.6k
3 个回答

本地<url>少了一个file:?

ojdbc6.jar 要手动下载,再导入本地仓库。

mvn install:install-file -Dfile={Path/to/your/ojdbc6.jar} -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
刘泽
  • 5
新手上路,请多包涵

配置数据库连接池的问题,需要配置一个主数据库。

宣传栏