3

I have a bigger project with multiple modules, all organized by Maven and Spring.

Now I got a "closed source" JAR and two additional files (basically sth. like 2 text files with some information needed for the classes in the JAR) that I want to add to my project.

The manual that came with the JAR and the two files only says "Add the JAR as a lib" and "Add the 2 files to your classpath". I (or my IDE) already managed to add the JAR, but how and where can I add the other 2 files?

Thanks in advance, kaolick

EDIT:

As it seems one of my colleagues already added the JAR and the two files to the repository. I just didn't know about it because he called in sick this week and didn't tell me before. :-/

4

4 回答 4

1

You should place the files in src/main/resources folder then they will be on the classpath. As for the jar you should add it to pom as a dependency, eg

<dependency>
        <groupId>test</groupId>
        <artifactId>myjar</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${basedir}/lib/myjar.jar</systemPath>
</dependency>
于 2013-11-12T10:18:03.567 回答
0

You can upload the jar file to your local repository and then reference it like a usual library within your maven configuration. You can upload the file from the command line:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

See the documentation for more details.

于 2013-11-12T10:01:21.513 回答
0

As far as I know there's no specific way to add resource files to a project in Netbeans but it's quite legal to do it simply by copying the files into src/main/resources directory with your favourite file manager. Netbeans will recognize new files in the project straightaway and update the view.

于 2013-11-12T20:02:18.490 回答
0

I had to add the 2 *.dat files to the src/main/resources directory and the following lines to the pom.xml

<resources>
    <resource>
        <directory>src/main/resources</directory>
            <includes>
                <include>*.dat</include>
            </includes>
        </resource>
    </resources>
</resources>
于 2013-11-13T11:48:37.760 回答