简体   繁体   中英

Maven Web project with Maven java application as a dependency?

I have a simple java application - maven project in my Netbeans IDE.

After I created Maven Web Application and added first project as a dependency Netbeans shows that everything is OK, and I can use all methods as well.

But in runtime I am getting

java.lang.ClassNotFoundException: com.example.dal.factory.PersistenceDaoFactory

Is it possible to make web project depending on simple java application without creating multimodule java EE application?

Yes, but you need to install your first project locally:

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

Setting up NetBeans to use a project as a dependency isn't the same thing as having a Maven artifact you can use in other Maven projects; for Maven, you need to have it in a Maven repo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM