Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven, jsp files in dependency

Tags:

maven-2

jsp

I'm using maven2 for dependency management. I have one project that contains some Java files and some jsp files and another project, a web project, that depends on the first project. How do I access the jsp files from the web project?

I can see that the jsp files are added to 1-0-SNAPSHOT-sources.jar and not 1-0-SNAPSHOT.jar (which is added as a dependency in the web projects pom.xml).

like image 225
vpalle Avatar asked Apr 22 '09 12:04

vpalle


People also ask

Where to put JSP files in Spring Boot project?

As per convention, we place our JSP files in the ${project. basedir}/main/webapp/WEB-INF/jsp/ directory.

How to create JSP file in eclipse Maven project?

For creating a jsp file explore the project by clicking the + icon -> right click on WebContent -> New -> jsp -> write your jsp file name e.g. index -> next -> Finish. Now JSP file is created, let's write some code.

What is groupId in Maven dependency?

groupId This element indicates the unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of a project and is typically based on the fully qualified domain name of your organization. For example org. apache. maven.


1 Answers

I think the correct Maven-way to do it would be to put the JSP files in your web project under /src/main/webapp. If that for some reason is not possible, you could use the Maven Dependency Plugin to copy the needed files into your webapp. Or, if you have a WAR project anyway, you could use an Overlay to copy the JSP-Files. The second option (which I'd recommend), would look something like this:

    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <configuration>
            <overlays>
              <overlay>
                <groupId>myGroupId</groupId>
                <artifactId>myArtifactId</artifactId>
                <type>jar</type>
                <includes>
                  <include>**/*.jsp</include>
                </includes>
                <targetPath>WEB-INF/pages</targetPath>
              </overlay>
            </overlays>
          </configuration>
        </plugin>
      </plugins>
    </build>
like image 147
Thomas Marti Avatar answered Sep 21 '22 17:09

Thomas Marti