Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
346 views
in Technique[技术] by (71.8m points)

java - how to use class file from another war

We have two different web application and we want to extend few controllers of one war into another war.

We are using maven to build the project.

to include war we have given its dependency as

<dependency>
            <groupId>com.abc.exchange</groupId>
            <artifactId>employer</artifactId>
            <version>2.3.M2-SNAPSHOT</version>
            <type>war</type>
            <scope>compile</scope>
        </dependency>

It is unable to build giving class not found exception.

Can any body help me out how to achieve this?

I am getting error maven build failed :

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project agent-war: Compilation failure: Compilation failure:
[ERROR] projectsrunk_newagentsrcmainjavacomplatformagentwebAgentEmployeeController.java:[22,41] cannot find symbol
[ERROR] symbol  : class EmployeeController
[ERROR] location: package com..platform.employer.web
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can define the war plugin to produce a separate jar file which is available via a classifier based on the configuration:

<configuration>
  ..
  <attachClasses>true</attachClasses>
  <archiveClasses>true</archiveClasses>
</configuration>

After that you can use this as a separate dependency in other projects. But the best to make a separate jar module out of it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...