简体   繁体   中英

Maven + Netbeans Debugging WAR Application

We have 2 Maven applications, a war application which contains our jsps and presentation layer code, and a shared library which contains our business layer code.

Before migrating to maven we had the shared library as a project reference of the WAR application. Whenever we built or debugged the WAR application in Netbeans, the shared library would get automatically compiled and built and any new changes were picked up automatically.

With Maven, it looks like any time we make a change to the shared library we now need to build the shared library project BEFORE debugging. Is there any way to retain the efficiency of the old method?

When we debug the WAR application is there any way to have Maven build the shared library dependency (local jar project) automatically whenever we debug?

In eclipse its just a matter of the auto build/ hot deploy set up correctly. Just make sure to have maven plugin installed and use it as the the builder for the project.

I don't imagine netbeans is much different.

Ok, I finally accomplished this using the maven invoker plugin:

<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>1.6</version>
<configuration>
    <projectsDirectory>../</projectsDirectory>
    <pomIncludes>
        <pomInclude>project1/pom.xml</pomInclude>
        <pomInclude>project2/pom.xml</pomInclude>
    </pomIncludes>
    <goals>
        <goal>install</goal>
    </goals>
</configuration>
<executions>
    <execution>
        <id>build-deps</id>
        <goals>
            <goal>install</goal>
        </goals>
    </execution>
</executions>

I highly doubt this is best practice, but it got the job done. You could install this into it's own profile to make sure it doesn't interfere with automated building.

The way that I've worked around this is to have a parent POM that encapsulates all of the sub-components:

myProject
 +- myProject-web
 +- myProject-bl
 +- myProject-da
 \- myProject-domain

Each is a separate project that builds into it's own maven dependency. Then, the parent POM simply includes the other projects:

<modules>
  <module>myProject-web</module>
  <module>myProject-bl</module>
  <module>myProject-da</module>
  <module>myProject-domain</module>
</modules>

Now, whenever you build myProject , maven will rebuild the sub-components if they are out of date. Since maven builds each sub-component individually, you will have each part in your Maven repo, accessible by any other project that needs to use one or more parts of your project.

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