Browse Source

fix '解决文件打包执行的问题'

tangs 3 năm trước cách đây
mục cha
commit
87bc07c2e7
2 tập tin đã thay đổi với 47 bổ sung2 xóa
  1. 39 0
      pom.xml
  2. 8 2
      src/main/java/com/wzkj/zhai/contact/Application.java

+ 39 - 0
pom.xml

@@ -54,4 +54,43 @@
 
     </dependencies>
 
+    <build>
+        <plugins>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.6</version>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <addClasspath>true</addClasspath>
+                            <classpathPrefix>lib/</classpathPrefix>
+                            <mainClass>com.wzkj.zhai.contact.Application</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <version>2.10</version>
+                <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>
+
+        </plugins>
+    </build>
+
+
 </project>

+ 8 - 2
src/main/java/com/wzkj/zhai/contact/Application.java

@@ -11,8 +11,11 @@ import java.nio.file.Paths;
 
 public class Application {
     public static void main(String[] args) {
-        System.out.println("halo");
-//        getAllFiles("docx");
+        String dir = "";
+        if (args.length > 0) {
+            dir = args[0];
+        }
+        getAllFiles(dir);
     }
 
     public static void parseParams(String[] args) {
@@ -22,6 +25,9 @@ public class Application {
 
     public static void merge(String dir, String filename) {
         String ext = FilenameUtils.getExtension(filename);
+        if (!ext.equals("docx") && !ext.equals("dox")) {
+            return;
+        }
         String answerDoc = filename.replace( "." + ext, "-y."+ext);
         String resultDoc = filename.replace( "." + ext, "-r."+ext);