Толстый Jar и Spring

0
16 дек 2018 00:53
Собственно сабж!
Прошу помощи.
Собираю jar с зависимостями, при запуске получаю ошибку.
IJ Idea запускает все нормально.


Ошибка:
 
...
Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/p]
Offending resource: class path resource [META-INF/spring/app-context.xml]
...


app-context.xm
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="provider" class="com.apress.prospring4.ch2.HelloWorldMessageProvider"/>

    <bean id="renderer" class="com.apress.prospring4.ch2.StandardOutMessageRenderer"
        p:messageProvider-ref="provider"/>
</beans>


HelloWorldSpringDI
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class HelloWorldSpringDI {
    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext
           ("META-INF/spring/app-context.xml");

        MessageRenderer mr = ctx.getBean("renderer", MessageRenderer.class);
        mr.render();
    }
}


pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.apress.prospring4.ch2</groupId>
    <artifactId>hello-world</artifactId>
    <packaging>jar</packaging>
    <version>4.0-SNAPSHOT</version>
    <name>hello-world</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring.version>4.0.2.RELEASE</spring.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>com.apress.prospring4.ch2.HelloWorldSpringDI</mainClass>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>dependency/</classpathPrefix>
                        </manifest>
                        <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>assemble-all</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

<!--            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>-->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <!--<index>true</index>-->
                        <manifest>
                            <mainClass>com.apress.prospring4.ch2.HelloWorldSpringDI</mainClass>
                            <!--<addClasspath>true</addClasspath>-->
                            <classpathPrefix>dependency/</classpathPrefix>
                        </manifest>
                        <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>

                    </archive>
                </configuration>
            </plugin>


        </plugins>
    </build>

</project>

Ответов: 1

0
17 дек 2018 10:32
Вопрос с снимается, решил. Проблема жила в настройках сборщика зависимостей.
Модераторы: wedens
Сейчас эту тему просматривают: Нет