小编D.R*_*.R.的帖子

无法使用maven-assembly-plugin设置类路径

我正在创建控制台应用程序 我想在jar文件conf夹中的文件外部配置文件,并希望将此文件夹注册为我的应用程序的类路径.

我运行mvn assembly:single命令,得到一个jar文件,但是当我尝试运行这个JAR时java -jar MyApplication.jar,它无法读取配置文件.

我有这个片段 pom.xml

<build>
    <finalName>MyApplication</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.7</version>  
            <configuration>
                <projectNameTemplate>
                    [artifactId]-[version]
                </projectNameTemplate>
                <wtpmanifest>true</wtpmanifest>
                <wtpapplicationxml>true</wtpapplicationxml>
                <wtpversion>2.0</wtpversion>
                <manifest>
                    ${basedir}/src/main/resources/META-INF/MANIFEST.MF
                </manifest>
            </configuration>

        </plugin>

        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <appendAssemblyId>false</appendAssemblyId>
                <archive>
                    <manifest>
                        <mainClass>com.my.test.App</mainClass>
                    </manifest>
                    <manifestEntries>
                        <Class-Path>.conf/</Class-Path>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

java maven-2 classpath executable-jar pom.xml

11
推荐指数
1
解决办法
1万
查看次数

Spring:异常启动过滤器springSecurityFilterChain

我正在尝试使用编写应用程序Spring 3.1.2-Release.应用服务器是Tomcat 7.当我启动服务器时,我收到此错误:

SEVERE:异常启动过滤器springSecurityFilterChain org.springframework.beans.factory.NoSuchBeanDefinitionException:否

名为'springSecurityFilterChain'的bean在org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:553)的org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1095)中定义. Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:277)位于org.springframework.context.support的org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197). AbstractApplicationContext.getBean(AbstractApplicationContext.java:1102)

这是我的配置文件:

web.xml
Run Code Online (Sandbox Code Playgroud)
<display-name>myTest</display-name>

<context-param>     
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>

<context-param>
    <param-name>defaultHtmlEscape</param-name>
    <param-value>true</param-value>
</context-param>

 <!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
    <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>

<!-- Processes application requests -->
<servlet>
    <servlet-name>springTest</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>springTest</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
Run Code Online (Sandbox Code Playgroud)

这是 root-context.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:c="http://www.springframework.org/schema/c" xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd …
Run Code Online (Sandbox Code Playgroud)

java spring web.xml configuration-files spring-security

10
推荐指数
1
解决办法
2万
查看次数

没有web.xml,无法启动spring mvc 4应用程序

我试图仅使用注释来部署spring mvc 4 没有web.xml文件的Web应用程序@Configuration.我有

public class WebAppInitializer implements WebApplicationInitializer {

@Override
public void onStartup(ServletContext servletContext)
        throws ServletException {
    WebApplicationContext context = getContext();
    servletContext.addListener(new ContextLoaderListener(context));
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet(
            "DispatcherServlet", new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("*.html");
}

private AnnotationConfigWebApplicationContext getContext() {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setConfigLocation("ge.dm.icmc.config.WebConfig");
    return context;
}
Run Code Online (Sandbox Code Playgroud)

}

我的WebConfig.java班级看起来像:

@Configuration    
@EnableWebMvc     
@ComponentScan(basePackages="ge.dm.icmc")    
public class WebConfig{

}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试启动应用程序时,我在日志中看到:

14:49:12.275 [localhost-startStop-1] DEBUG oswcsAnnotationConfigWebApplicationContext - 无法为config location []加载类 - 尝试打包扫描.抛出java.lang.ClassNotFoundException:

如果我尝试添加web.xml文件,则会正常启动.

spring web.xml spring-mvc servlet-3.0

1
推荐指数
1
解决办法
3782
查看次数

在jboss 7.1中,两个在不同EAR项目中具有相同名称的ejb jar文件相互冲突

我正在将项目迁移Jboss 5.1jboss 7.1

我有两个EAR,运行在同一个Jboss上.它们包含内部的ejb项目,并且services.jar由于finalname标记而调用了两个ejb jar文件 EJB_PROJECT/pom.xml

    <build>
        <finalName>services</finalName>
            .....
    </build>
Run Code Online (Sandbox Code Playgroud)

在Jboss 5.1上它工作正常,但现在我得到错误:

    18:07:16,858 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.deployment.subunit."my1.ear"."services.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."my1.ear"."services.jar".INSTALL: Failed to process phase INSTALL of subdeployment "services.jar" of deployment "my1.ear"  
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]  
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_45]  
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_45]  
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_45]  
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018027: Failed to add JBoss Web deployment service  
    at …
Run Code Online (Sandbox Code Playgroud)

ejb pom.xml jboss5.x maven jboss7.x

0
推荐指数
1
解决办法
747
查看次数