简体   繁体   English

Maven模块作为对Web应用程序的依赖

[英]Maven module as dependency on a Web Application

ich have tree modules for my projec, server,client and core. ich有用于我的项目,服务器,客户端和核心的树模块。 Core module should be imported as jar dependency in other modules. 核心模块应作为jar依赖项导入到其他模块中。 On eclipse i see no warnings, but if i'm starting the application i'm getting following error : 在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

this interface is imported on a HelloServiceImpl. 此接口在HelloServiceImpl上导入。 HelloServiceImpl is created on the beans as following : 在bean上创建HelloServiceImpl,如下所示:

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

i have removed the namespaces because of link protection of stackoverflow :) By the way, my pom.xml's are : 我已经删除了命名空间,因为stackoverflow的链接保护:)顺便说一句,我的pom.xml是:

for core : 对于核心:

<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>

Server : 服务器:

<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>

Client : 客户:

<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>

And the parent pom : 和父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>

Thanks you very much for your helps :) 非常感谢您的帮助:)


Thank your for your help, i've removed it but the error is the same 感谢您的帮助,我已将其删除,但错误相同

<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>

I'm not sure what this would actually do, but in the server's POM you are listing core as a dependency and then also excluding it: 我不确定这实际上会做什么,但是在服务器的POM中,您将核心列为依赖项,然后也将其排除在外:

<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>

Why would you do this? 你为什么要这样做? Exclusions are used to tell Maven to ignore some dependencies dragged in by other dependencies in your build.Try removing the exclusion. 排除项用于告诉Maven忽略构建中其他依赖项拖入的某些依赖项。尝试删除该排除项。

You likely just need a mvn clean install in the parent directory to get a fresh war file. 您可能只需要在父目录中进行mvn clean install全新mvn clean install即可获取新的war文件。 Otherwise, clarify what you mean by "if i'm starting the application": using the maven jetty plugin? 否则,请弄清楚“如果我正在启动应用程序”是什么意思:使用Maven Jetty插件? Deploying to Tomcat? 部署到Tomcat? Something else? 还有吗

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM