Is it best to Mavenize your project jar files or put them in WEB-INF/lib?

…衆ロ難τιáo~ 提交于 2019-12-02 07:00:35

I've been doing the same that you do with the command line, but by configuring maven-install-plugin in my POM (please read the note at the end):

     <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <executions>
                <execution>
                    <id>install-vegetables</id>
                    <phase>initialize</phase>
                    <goals>
                        <goal>install-file</goal>
                    </goals>
                    <configuration>
                        <file>${project.basedir}/lib/vegetables-1.0.jar</file>
                        <groupId>vegetables</groupId>
                        <artifactId>potatoes</artifactId>
                        <version>1.0</version>
                        <packaging>jar</packaging>
                    </configuration>
                </execution>
                <execution>
                    <id>install-minerals</id>
                    <phase>initialize</phase>
                    <goals>
                        <goal>install-file</goal>
                    </goals>
                    <configuration>
                        <file>${project.basedir}/lib/minerals-1.0.jar</file>
                        <groupId>minerals</groupId>
                        <artifactId>rocks</artifactId>
                        <version>1.0</version>
                        <packaging>jar</packaging>
                    </configuration>
                </execution>
            </executions>
        </plugin>

It is much less efficient, because files get installed over and over, but it is much less annoying than making it manually. Anyway, I think you should give it a try.

All your dependencies should reside under the local repository. According to the Maven convention/best practices, you should not keep jar files in your project.

Convert your project to a fully war based Maven project. This will place all your dependencies (jar files) under your webapp's WEB-INF/lib directory. Thus you will not have to worry about long paths.

You just need to add the dependencies in your pom.xml file, no need to install them manually. Maven will download the libraries and put it in your local repository whenever needed. Only if you want to use third party(custom) libraries, you may go for installing it in your local repository.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!