The Java Project (non-web) that uses MAVEN to package spring in idea

Source: Internet
Author: User

The Javaweb project, which has been used to install the MAVEN package for spring, is packaged with MVN assembly:assembly, this time wrapping the non-web spring project, encountering many problems and recording the correct steps.

1. Configure Pom.xml

There is no need to assembly, because Assembly will only be in the packaging of the first encounter of the file into the jar package, after the encounter will skip. That is to say, assembly my spring description file is ignored. The error is: Can't find spring-context.xml (my config spring xml), so here with Maven-shade-plugin

1<build>2<plugins>3<plugin>4<groupId>org.apache.maven.plugins</groupId>5<artifactId>maven-shade-plugin</artifactId>6<version>1.4</version>7<executions>8<execution>9<phase> Package</phase>Ten<goals> One<goal>shade</goal> A</goals> -<configuration> -<transformers> the<Transformer -implementation= "Org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" > -<mainClass>com.peak.App</mainClass> -</transformer> +<Transformer -implementation= "Org.apache.maven.plugins.shade.resource.AppendingTransformer" > +<resource>META-INF/spring.handlers</resource> A</transformer> at<Transformer -implementation= "Org.apache.maven.plugins.shade.resource.AppendingTransformer" > -<resource>META-INF/spring.schemas</resource> -</transformer> -<Transformer -implementation= "Org.apache.maven.plugins.shade.resource.AppendingTransformer" > in<resource>META-INF/spring.tooling</resource> -</transformer> to</transformers> +</configuration> -</execution> the</executions> *</plugin> $</plugins>Panax Notoginseng</build>
Configuration in 2.idea

Because idea integrates Maven, there's no need to install MAVEN specifically

  

  

  

3.clean and package (double-click to run)

The Java Project (non-web) that uses MAVEN to package spring in idea

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.