0

使用这个项目结构,我无法将 sqljdbc4.jar 安装到我的本地 maven 存储库。

这是 LiferayBuild/pom.xml

<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>
    <groupId>...</groupId>
    <artifactId>LiferayBuild</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>
    <name>LiferayBuild</name>
    <description>Liferay Aggregator Project (build modules)</description>
    <properties>
        ...
    </properties>
    <modules>
        ...
        <module>../Liferay</module>
    </modules>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <groupId>com.microsoft.sqlserver</groupId>
                    <artifactId>sqljdbc4</artifactId>
                    <version>4.0</version>
                    <file>${basedir}/lib/sqljdbc4-4.0.jar</file>
                    <packaging>jar</packaging>
                    <generatePom>false</generatePom>
                    <pomFile>../Liferay/pom.xml</pomFile>
                </configuration>
                <executions>
                    <execution>
                        <id>inst_sql</id>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <phase>install</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

这是 Liferay/pom.xml

<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>
<groupId>...</groupId>
<artifactId>Liferay</artifactId>
<version>1.2.1</version>
<name>Liferay</name>
<description>Liferay Connector</description>
<properties>
    ...
</properties>

<dependencies>
    ...
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>sqljdbc4</artifactId>
        <version>4.0</version>
    </dependency>
    ...
</dependencies>
<!-- Build Settings -->
<build>
    <resources>
        ...
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        ...
    </plugins>
</build>
<pluginRepositories>
    ...
</pluginRepositories>
<profiles>
    <profile>
        ...
    </profile>
</profiles>

当我运行为... Maven 安装时,我得到了 BUILD FAILURE

[ERROR] Failed to execute goal on project Liferay: Could not resolve dependencies for project com.realsoft:Liferay:jar:1.2.1: Failure to find com.microsoft.sqlserver:sqljdbc4:jar:4.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

我该怎么做才能将 jar 安装到我的本地存储库?我已经尝试过来自http://blog.valdaris.com/post/custom-jar/的建议,但没有结果。请帮忙!

4

1 回答 1

1

谢谢,我用过

<phase>clean</phase>

并将 lib 文件夹移动到我的多模块项目的 basedir 中。

于 2016-03-10T11:46:26.123 回答