Wildfly jar客户端巨大

时间:2018-09-26 12:19:50

标签: java maven wildfly

当我导出客户端jar时(使用eclipse的Export as Runnable jar),文件大约30MB,包括很多服务器依赖项,例如Hibernate,大约16MB,等等。是否可以将其精简,客户端真的需要休眠吗?带有注释的实体来回共享。

我的Eclipse工作区是这样设置的:

  • client-project
  • ejb-server-project
  • 网络服务器项目
  • ear-project

ear-project被发布到服务器,并且包含ejb-project和web-project(带有REST接口)。客户端进入一个单独的.jar文件,该文件被复制到网络驱动器中供人们使用。它使用ejb,jms,主要用于在服务器处理数据库访问,计算等操作时显示数据。

客户端pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>package.bde.client</groupId>
    <artifactId>bde-client</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>package.bde.client</name>

    <dependencies>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-jms-client-bom</artifactId>
            <type>pom</type>
            <version>10.1.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-ejb-client-bom</artifactId>
            <type>pom</type>
            <version>10.1.0.Final</version>
        </dependency>

        <dependency>
            <groupId>package.bde.server.sessionbean</groupId>
            <artifactId>bde-server</artifactId>
            <version>1.0</version>
            <type>ejb-client</type>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jfree</groupId>
            <artifactId>jfreechart</artifactId>
            <version>1.0.19</version>
        </dependency>
        <dependency>
            <groupId>com.miglayout</groupId>
            <artifactId>miglayout-swing</artifactId>
            <version>4.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.7</version>
        </dependency>
        <dependency>
            <groupId>com.github.lgooddatepicker</groupId>
            <artifactId>LGoodDatePicker</artifactId>
            <version>10.3.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>package.bde.client.BdeClient</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <parent>
        <groupId>package.bde</groupId>
        <artifactId>comp-bde</artifactId>
        <version>1.0</version>
        <relativePath>../comp-bde</relativePath>
    </parent>
</project>

ear pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>package.bde</groupId>
    <artifactId>comp-bde</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <name>comp-bde</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.10.1</version>
                <configuration>
                    <version>6</version>
                    <defaultLibBundleDir>lib</defaultLibBundleDir>
                    <modules>
                        <webModule>
                            <groupId>package.bde.web</groupId>
                            <artifactId>bde-web</artifactId>
                            <bundleFileName>bde-web.war</bundleFileName>
                            <contextRoot>/bde</contextRoot>
                        </webModule>
                        <ejbModule>
                            <groupId>package.bde.server</groupId>
                            <artifactId>bde-server</artifactId>
                            <bundleFileName>bde-server.jar</bundleFileName>
                        </ejbModule>
                        <jarModule>
                            <groupId>package.bde.client</groupId>
                            <artifactId>bde-client</artifactId>
                            <bundleDir>/</bundleDir>
                            <bundleFileName>bde-client.jar</bundleFileName>
                            <includeInApplicationXml>true</includeInApplicationXml>
                        </jarModule>
                    </modules>
                    <displayName>comp BDE</displayName>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <modules>
        <module>../bde-server</module>
        <module>../bde-web</module>
        <module>../bde-client</module>
    </modules>

    <repositories>
        <repository>
            <id>jboss</id>
            <name>JBoss Releases</name>
            <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
        </repository>
        <repository>
            <id>central</id>
            <name>Maven Central</name>
            <url>http://central.maven.org/maven2/</url>
        </repository>
        <repository>
            <id>apache</id>
            <name>Apache Releases</name>
            <url>https://repository.apache.org/content/repositories/releases/</url>
        </repository>
    </repositories>
</project>

ejb pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>package.bde.server.sessionbean</groupId>
    <artifactId>bde-server</artifactId>
    <packaging>ejb</packaging>

    <name>bde-server</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <ejbVersion>3.1</ejbVersion>
                    <generateClient>true</generateClient>
                    <archive>
                        <manifestEntries>
                            <Dependencies>com.mysql, org.hibernate,
                                com.healthmarketscience.jackcess, org.quartz-scheduler,
                                com.microsoft.sqlserver, net.ucanaccess.jdbc,
                                org.apache.commons.commons-lang3</Dependencies>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>7.0</version>
            </dependency>
            <dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>wildfly-javaee7</artifactId>
                <version>10.1.0.Final</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <parent>
        <groupId>package.bde</groupId>
        <artifactId>comp-bde</artifactId>
        <version>1.0</version>
        <relativePath>../comp-bde</relativePath>
    </parent>
</project>

0 个答案:

没有答案