【问题标题】:multi module maven project module expose as soap web service多模块 Maven 项目模块公开为肥皂网络服务
【发布时间】:2015-03-17 11:53:37
【问题描述】:

我有一个多模块 maven-spring 项目。以下是结构-

ParentService
---ChildService-service
---ChildService-core
---ChildService-web
---ChildService-wsClient
---ChildService-mongo

我创建了一个名为 ChildService-wsService 的新模块,我将在其中编写方法并公开为 Axis2 SOAP Web 服务。我已经能够在这个模块项目的类中编写独立的方法并公开为服务,但我想调用 ChildService-service 模块的方法。

当我尝试调用 ChildService-service 模块的方法时,它给了我像 NoClassDefFoundError 这样的错误。

以下是示例代码--

public class HelloWorld  {
@Autowired
private  ITestService iTestService;
@Autowired
ICommonService commonService;



public String getVal(String s){
    return s+"...testing...";
}

public String getValFfmService(){
    iTestService=new TestServiceImpl();
    return iTestService.test();

}

我收到如下错误--

Error: java.lang.NoClassDefFoundError: com/service/test/business/ITestService at java.lang.Class.forName0

如果我在课堂上包含以下行,那么我也会收到 classnotfound 错误。

extends SpringBeanAutowiringSupport

【问题讨论】:

    标签: spring web-services maven soap module


    【解决方案1】:

    您需要将您需要的其他项目作为依赖项包含在内,例如,在您的 pom.xml 中:

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>ChildService-service</artifactId>
            <version>${project.version}</version>
            <scope>compile</scope>
        </dependency>
    
        ...
    </dependencies>
    

    然后你需要在你的本地存储库中安装这些依赖项(mvn clean install 会这样做),或者,在 Eclipse 中,你需要激活Workspace resolution(右键单击你的模块,Maven > Enable Workspace Resolution)。

    【讨论】:

    • 谢谢!我已经添加了。以下是我的 pom--&lt;dependency&gt; &lt;groupId&gt;com.sahaj.portal&lt;/groupId&gt; &lt;artifactId&gt;ChildService-core&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.sahaj.portal&lt;/groupId&gt; &lt;artifactId&gt;ChildService-service&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;/dependency&gt;
    • 在本地存储库中安装后,您还需要在 Eclipse 中进行 Maven 更新(右键单击,Maven > 更新项目;检查字段Force Update of Snapshots/Releases)。有用吗?
    • 出现以下错误 Servlet AxisAdminServlet 抛出 load() 异常:java.lang.ClassNotFoundException: org.springframework.web.context.support.SpringBeanAutowiringSupport 来自 [Module"deployment.ChildService-wsServiceEAR.ear.ChildService- wsService.war:main" 来自服务模块加载器]
    • 无法在服务模块加载器的模块“deployment.ChildService-wsServiceEAR.ear.ChildService-wsService.war:main”中定义类 com.test.HelloWorld:java.lang.LinkageError:无法链接com/test/HelloWorld(来自服务模块加载器的模块“deployment.ChildService-wsServiceEAR.ear.ChildService-wsService.war:main”)
    • 嗯,它们是使用ServiceLoader机制自动加载的服务吗?
    猜你喜欢
    • 1970-01-01
    • 2011-06-11
    • 2021-07-29
    • 2017-01-16
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-14
    相关资源
    最近更新 更多