开发者

How to handle the dependencies which are not present in the maven/spring repository?

I have an application whose dependencies are being handled by maven.I need to know, how can i handle the dependencies which are not present in the remote repository. I dont want开发者_运维知识库 to use a local repository. Need help.


I can see a few solutions :

  1. Find another remote repository having the dependencies you need (jarvana, findjar etc) are your friends

  2. Wait for the maintener of the dependencies make them available on a remote repository (close your eyes, cross your fingers ... and wait)

  3. Setup your own remote repository with the dependencies you need (oragnization repository)

  4. Put your dependencies in your calsspath manually or through your favorite IDE :p


When you say

the dependencies which are not present in the remote repository

I assume you mean repositories not present in maven central (the default repository). If so, as Stephen suggested, you would want to add a repositories section in your pom with a reference to other repositories which has the dependencies.

If there are no remote repositories which has your dependencies and you do not want to install them locally to your local repository, then maven will automatically handle this situation - it will given an error and fail to build.


By default maven-compiler-plugin uses java 1.3 for compilation. You would need to configure it to use jdk5/jdk6. Add following to POM xml.

<build>
<plugins>
    <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
</plugins>
</build>


If you don't want to use a local repository then perhaps you could declare them with a system scope. Documented here

Example:

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>javax.sql</groupId>
      <artifactId>jdbc-stdext</artifactId>
      <version>2.0</version>
      <scope>system</scope>
      <systemPath>${java.home}/lib/rt.jar</systemPath>
    </dependency>
  </dependencies>
  ...
</project>

I would really recommend using a local repository. Very easy to setup and install Nexus. The system scope is really designed to include extensions to the JVM.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜