I build a mvn project in eclipse to add some neo4j server plugins and unmanaged extentions. When I run
mvn clean install
the result jar package just has the classes in my own project not include related dependencies such as spring data neo4j jars.
when add the following codes in pom.xml
<build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>fully.qualified.MainClass</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins> </build>
and run
mvn clean compile assembly:single
the result jar include all dependencies classes, also include the neo4j jars, which i expect the final jar exclude the neo4j classes that provoided by neo4j server.
Actually, using eclipse pom.xml editor to check the dependencies tree, find out neo4j related jars transitive dependencied by which jar, and exclude it with the following sinppet
<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-neo4j-aspects</artifactId> <version>${neo4j.springdata.version}</version> <exclusions> <exclusion> <groupId>org.neo4j</groupId> <artifactId>*</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> </exclusion> </exclusions> </dependency>
Some others suggest using shade plugin to exclude some dependencies, I tried but faild without any clues
but I keep it in the pom.xml and using it to package the final jar
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.3</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <createDependencyReducedPom>false</createDependencyReducedPom> <artifactSet> <excludes> <exclude>org.neo4j:*:jar:*</exclude> </excludes> </artifactSet> </configuration> </execution> </executions> </plugin>
mvn clean package shade:shade
use the command to show project dependencies
mvn dependency:tree -Ddetail=true
----------------------------
when I deploy my extentions jar with spring data neo4j related dependencies in plugins dir of neo4j server
I start neo4j server. in
015-03-27 02:52:09.410+0000 ERROR [o.n.s.CommunityBootstrapper]: Failed to start Neo Server on port [7474] org.neo4j.server.ServerStartupException: Starting Neo4j Server failed: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context] Offending resource: class path resource [META-INF/spring/application-context.xml]
google result helps
http://www.baeldung.com/unable-to-locate-spring-namespacehandler-for-xml-schema-namespace
http://robert-reiz.com/2011/11/14/832/
altering pom.xml
<build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.0</version> <executions> <execution> <phase>package</phase> <goals><goal>shade</goal></goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.schemas</resource> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.3</version> </plugin> </plugins> </build>