2017-05-04 85 views
1

我有一個hadoop任務作爲spring-boot應用程序的組件,我用maven-assembly-plugin分別編譯每個文件。java-Maven assembly plugin build class classpath

 <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <configuration> 
       <descriptorRefs> 
        <descriptorRef>jar-with-dependencies</descriptorRef> 
       </descriptorRefs> 
      </configuration> 
      <executions> 
       <execution> 
        <id>make-assembly</id> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

在目標目錄,如果我開始與服務器:

java -cp target/xx-server-0.0.1-SNAPSHOT-jar-with-dependencies.jar com.example.MyApplication 

它發生錯誤:

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. 

,這是由缺少類路徑造成的。我怎樣才能爲jar設置classpath?或者我需要編寫一個腳本來啓動我的服務器?在IDE中的服務器可以與類路徑標誌啓動:

/usr/lib/jvm/jdk1.8.0_121/bin/java -XX:TieredStopAtLevel=1 
-noverify -Dspring.output.ansi.enabled=always 
-javaagent:/home/knh190/idea/idea-IU 171.3780.95/lib/idea_rt.jar=39181:/home/knh190/idea/idea-IU-171.3780.95/bin 
-Dfile.encoding=UTF-8 
-classpath # list of dependencies 

回答

0

你可以嘗試這樣的:

<configuration> 
    <descriptorRefs> 
     <descriptorRef>jar-with-dependencies</descriptorRef> 
    </descriptorRefs> 
    <archive> 
     <manifest> 
      <mainClass>com.my.App</mainClass> 
     </manifest> 
     <manifestEntries> 
      <Class-Path>your-classpath-here</Class-Path> 
     </manifestEntries> 
    </archive> 
</configuration> 
+0

當我反編譯的jar,依賴被包括在內,但沒有被發現。我真的需要再次手動包含classpath嗎? – knh190

相關問題