简体   繁体   English

在spring mvc maven项目中添加外部项目

[英]adding external project in spring mvc maven project

I am new in Spring MVC. 我是Spring MVC的新手。 I am trying to add my core Maven project into Spring MVC Maven project. 我正在尝试将我的核心Maven项目添加到Spring MVC Maven项目中。 It build successfully and i can see the respective jar files in "target\\project.war\\WEB-INF\\lib" but it throws error on glassfish console. 它构建成功,我可以在“target \\ project.war \\ WEB-INF \\ lib”中看到相应的jar文件,但它会在glassfish控制台上抛出错误。

Info: visiting unvisited references Info: visiting unvisited references Severe: Exception while deploying the app [IDSNGWeb] Severe: Exception during lifecycle processing java.lang.NullPointerException at com.sun.enterprise.deployment.EnvironmentProperty.isConflictResourceGroup(EnvironmentProperty.java:433) at com.sun.enterprise.deployment.ServiceReferenceDescriptor.isConflict(ServiceReferenceDescriptor.java:699) at org.glassfish.web.deployment.descriptor.WebFragmentDescriptor.combineServiceReferenceDescriptors(WebFragmentDescriptor.java:210) at org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl.addJndiNameEnvironment(WebBundleDescriptorImpl.java:277) at org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl.addCommonWebBundleDescriptor(WebBundleDescriptorImpl.java:268) at org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl.addWebBundleDescriptor(WebBundleDescriptorImpl.java:156) at org.glassfish.web.deployment.archivist.WebArchivist.postAnnotationProc 信息:访问未访问的引用信息:访问未访问的引用严重:部署应用程序时出现异常[IDSNGWeb]严重:生命周期处理期间的异常com.sun.enterprise.deployment.EnvironmentProperty.isConflictResourceGroup(EnvironmentProperty.java:433)中的java.lang.NullPointerException在com.sun.enterprise.deployment.ServiceReferenceDescriptor.isConflict(ServiceReferenceDescriptor.java:699)在org.glassfish.web.deployment.descriptor.WebFragmentDescriptor.combineServiceReferenceDescriptors(WebFragmentDescriptor.java:210)在org.glassfish.web.deployment.descriptor位于org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl.addCommonWebBundleDescriptor(WebBundleDescriptorImpl.java:268)的.WebBundleDescriptorImpl.addJndiNameEnvironment(WebBundleDescriptorImpl.java:277)org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl.addWebBundleDescriptor(WebBundleDescriptorImpl.java) :156)at org.glassfish.web.deployment.archivist.WebArchivist.postAnnotationProc ess(WebArchivist.java:354) at org.glassfish.web.deployment.archivist.WebArchivist.postAnnotationProcess(WebArchivist.java:91) at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:421) at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:396) at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:271) at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:280) at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:241) at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:161) at org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:203) at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:227) at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96) at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:8 ess(WebArchivist.java:354)atg.glassfish.web.deployment.archivist.WebArchivist.postAnnotationProcess(WebArchivist.java:91)at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:421)在com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:396)的com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:271)com.sun.enterprise.deployment .archivist.Archivist.open(Archivist.java:280)at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:241)at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory) .java:161)org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:203)org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:227)org。 com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:8)中的glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96) 81) at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:821) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:377) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219) at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:360) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534) at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565) at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subjec 81)com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:821)at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:377)at com.sun.enterprise位于com.sun.enterprise.v3.admin.CommandRunnerImpl $。 (CommandRunnerImpl.java:539)at com.sun.enterprise.v3.admin.CommandRunnerImpl $ 2 $ 1.run(CommandRunnerImpl.java:535)at java.security.AccessController.doPrivileged(Native Method)at javax.security.auth.Subject .doAs(Subject.java:360)at com.sun.enterprise.v3.admin.CommandRunnerImpl $ 2.execute(CommandRunnerImpl.java:534)at com.sun.enterprise.v3.admin.CommandRunnerImpl $ 3.run(CommandRunnerImpl.java) :565)at com.sun.enterprise.v3.admin.CommandRunnerImpl $ 3.run(CommandRunnerImpl.java:557)at java.security.AccessController.doPrivileged(Native Method)at javax.security.auth.Subjec t.doAs(Subject.java:360) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464) at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722) at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534) at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224) at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler. t.doAs(Subject.java:360)位于com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)的com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java: 1464)在com.sun.enterprise.v3.admin.CommandRunnerImpl.access $ 1300(CommandRunnerImpl.java:109)com.sun.enterprise.v3.admin.CommandRunnerImpl $ ExecutionContext.execute(CommandRunnerImpl.java:1846)at com。在com.sun.enterprise.v3的com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)的sun.enterprise.v3.admin.CommandRunnerImpl $ ExecutionContext.execute(CommandRunnerImpl.java:1722)。 admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)在org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)在com.sun.enterprise.v3.services.impl.ContainerMapper $ HttpHandlerCallable。在com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)调用(ContainerMapper.java:459)org.glassfish.grizzly.http.server.HttpHandler。 runService(HttpHandler.java:206) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIO org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)的orService.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)中的runService(HttpHandler.java:206)在在org.glassfish.grizzly.filterchain.DefaultFilterChain org.glassfish.grizzly.filterchain.ExecutorResolver $ 9.execute(ExecutorResolver.java:119)在org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)。 executeChainPart(DefaultFilterChain.java:200)在org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)在org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)在org.glassfish .grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)在org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)在org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java :112)在org.glassfish.grizzly.strategies.WorkerThreadIO Strategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) at java.lang.Thread.run(Thread.java:748) Strategy.run0(WorkerThreadIOStrategy.java:117)在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access $ 100(WorkerThreadIOStrategy.java:56)在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137 )org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:591)位于java.lang.Thread的org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:571)。运行(Thread.java:748)

Severe: Exception while deploying the app 严重:部署应用程序时出现异常

i am not able to add any maven project or jar files. 我无法添加任何maven项目或jar文件。 Highly possible i am not doing right on adding dependency. 我很可能在添加依赖性方面做得不对。 If anyone could help me with it. 如果有人可以帮助我。 Thanks in advance. 提前致谢。

Below is my POM file. 下面是我的POM文件。

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0.0

<groupId>com.agnisys.idsng</groupId>
<artifactId>IDSNGWeb</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>IDSNGWeb</name>

<properties>
    <endorsed.directory>${project.build.directory}/endorsed</endorsed.directory>
    <!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>-->
    <spring.version>3.2.13.RELEASE</spring.version>
  <!--  <property name="AS_HOME" value="C:\Users\Agnisys56\Documents\GitHub\IDS-NextGen\IDSNGWeb\src\main\webapp"/> -->
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>com.agnisys</groupId>
        <artifactId>IDSManager</artifactId>
        <version>1.0</version>
    </dependency>

</dependencies>


<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.directory}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.directory}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>7.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

There is a way I've used before is to create a main project which contains your two projects, The main project should have the main POM file that have shared dependencies between of all child projects, and each of your projects should have their own POM configuration. 我之前使用过的方法是创建一个包含两个项目的主项目。主项目应该有一个主POM文件,该文件在所有子项目之间具有共享依赖关系,并且每个项目都应该有自己的POM组态。 You can then import in the spring MVC project POM your second child project. 然后,您可以在spring MVC项目POM中导入您的第二个子项目。 More details : 更多细节 :

https://howtodoinjava.com/maven/maven-parent-child-pom-example/ https://howtodoinjava.com/maven/maven-parent-child-pom-example/

You can also use something called Multi-module project : 您还可以使用称为多模块项目的东西:

https://www.baeldung.com/maven-multi-module https://www.baeldung.com/maven-multi-module

https://www.mkyong.com/maven/maven-how-to-create-a-multi-module-project/ https://www.mkyong.com/maven/maven-how-to-create-a-multi-module-project/

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

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