Friday, July 18, 2014

Using spring framework in Standalone Java Project

Hi,
if you want to use spring framework in your java application (jar) you need to take care for something.

First of all you need to use apache-shade-plugin for read your applicationContext.xml file in jar.

Here is sample pom.xml

 


<groupid>tr.com.kiraz</groupid>
    <artifactid>fatura</artifactid>
    <version>1.0.0</version>
    <packaging>jar</packaging>
    <name>fatura</name>

    <properties>
        <project .build.sourceencoding="">UTF-8</project>
        <project .reporting.outputencoding="">UTF-8</project>
        <argline>-Dfile.encoding=UTF-8</argline>
    </properties>


    <build>
        <plugins>
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-compiler-plugin</artifactid>
                <version>2.3.2</version>
                <configuration>
                    <source></source>1.6
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <!-- Build an executable JAR -->
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-jar-plugin</artifactid>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addclasspath>true</addclasspath>
                            <mainclass>tr.com.tnbkep.BankaFatura</mainclass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>


            <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>
                            <transformers>
                                <!--<transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>-->
                                <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>
    </build>

    

No comments:

Post a Comment

How can we use svg file as a icon of v-btn (vuetify button) ?

<template>   <v-btn>     <CustomIcon />     Click me   </v-btn> </template> <script> // Import your SVG ...