Finding missing Maven artifacts

后端 未结 9 2234
你的背包
你的背包 2021-01-02 05:01

I\'m new to Maven, and struggling with adding dependencies. I\'m trying to convert an existing project to Maven, and after adding the dependencies for all the jars in my ref

9条回答
  •  自闭症患者
    2021-01-02 05:55

    It's more likely that your POM definition is not correct for log4j. Everything relating to log4j should be readily available in maven.

    Also, if you know the name of the bundle (such as log4j) you can almost always do a quick google search "[bundle name] maven pom" within the first few hits you should either get the maven repo containing a quick snippet on how to include it, or the actual website for the bundled up jar and the maven instructions.

    For example log4j:

    
        
            log4j
            log4j
            1.2.16
        
     
    

    Sometimes though you just need to specify the repository to find the item in (if it's not hosted in the greater maven repositories)

    You can specify a new repository like so

    
        
            Java.Net
            http://download.java.net/maven/2/
        
    
    

    Finally when you absolutely cannot find the artifact already maven'd up for you (this is usually true for proprietary jars and or drivers that you cannot include with your project) you can have the user manually install the item via command line

    mvn install:install-file -DgroupId=[group-id] -DartifactId=[artifact-id] -Dversion=[version] -Dfile=/path/to/the/file -Dpackaging=[type]

    You can then reference it in your maven file using the information described above

    For example I have a custom reference for a salesforce.com project

    mvn install:install-file -DgroupId=com.salesforce -DartifactId=wsc -Dversion=22 -Dfile=\tsclient\H\development\java\wsc-22.jar -Dpackaging=jar

    To access it in maven:

    
        com.salesforce
        wsc
        22
    
    

    Finally, you can find the jars (or their maven info) at their respective websites (please note I'm just basing these links off the jar names, these may not be the actual websites, well sans the log4j which I know to be correct)

    Stax

    Clover

    Log4j

提交回复
热议问题