gpt4 book ai didi

java - Maven 模块作为 Web 应用程序的依赖项

转载 作者:行者123 更新时间:2023-12-01 05:52:11 25 4
gpt4 key购买 nike

ich 有我的项目、服务器、客户端和核心的树模块。核心模块应作为其他模块中的 jar 依赖项导入。在 Eclipse 上我没有看到任何警告,但是如果我启动应用程序,我会收到以下错误:

Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [at.ac.tuwien.inso.verteilte.service.HelloServiceImpl] for bean with name 'helloServiceImpl' defined in ServletContext resource [/WEB-INF/appContext.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: at/ac/tuwien/inso/verteilte/services/IHelloService

Caused by: java.lang.ClassNotFoundException: at.ac.tuwien.inso.verteilte.services.IHelloService

此接口(interface)在 HelloServiceImpl 上导入。 HelloServiceImpl 在 bean 上创建,如下所示:

<jaxws:endpoint id="helloService" implementorClass="at.ac.tuwien.inso.verteilte.service.HelloServiceImpl">

由于 stackoverflow 的链接保护,我已经删除了命名空间:)顺便说一句,我的 pom.xml 是:

对于核心:

<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>verteiltepaxen-parent</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<name>core</name>
<packaging>jar</packaging>
<description>Verteilte Praxen - core</description>
<build>
<finalName>core-1.0-SNAPSHOT</finalName>
</build>
</project>

服务器:

<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>verteiltepaxen-parent</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>server</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>server</name>
<description>Verteilte Praxen - Server</description>
<dependencies>
<dependency>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>core</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
</dependencies>
</dependencyManagement>
<build>
<finalName>server-1.0-SNAPSHOT</finalName>
</build>
</project>

客户端:

<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>verteiltepaxen-parent</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>client</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>client</name>
<description>Verteilte Praxen - Client</description>
<dependencies>
<dependency>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
</dependencies>
</dependencyManagement>
<build>
<finalName>client-1.0-SNAPSHOT</finalName>
</build>
</project>

和父pom:

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>verteiltepaxen-parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>verteiltepaxen Maven Webapp</name>
<properties>
<cxf.version>2.2.3</cxf.version>
<spring.version>2.5.6.SEC02</spring.version>
</properties>
<dependencies>
... other dependencies ...
</dependencies>
<repositories>
... Repositories ...
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<projectNameTemplate>verteiltepaxen-parent-1.0-SNAPSHOT</projectNameTemplate>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.8</version>
<configuration>
<!-- Configure the webapp -->
<contextPath>/verteiltepaxen</contextPath>
</configuration>
</plugin>
</plugins>
<finalName>verteiltepaxen-parent-1.0SNAPSHOT</finalName>
</build>
<modules>
<module>client</module>
<module>server</module>
<module>core</module>
</modules>
</project>

非常感谢您的帮助:)

<小时/>

感谢您的帮助,我已将其删除,但错误仍然相同

<dependencies>
<dependency>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>

最佳答案

我不确定这实际上会做什么,但在服务器的 POM 中,您将 core 列为依赖项,然后将其排除:

<dependency>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>core</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
</exclusion>
</exclusions>
</dependency>

你为什么要这样做?排除用于告诉 Maven 忽略构建中其他依赖项拖入的某些依赖项。尝试删除排除。

关于java - Maven 模块作为 Web 应用程序的依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4320701/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com