最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

IntelliJ IDEA打開多個Maven的module且相互調(diào)用代碼的方法

 更新時間:2019年02月02日 11:09:39   作者:silentwolfyh  
這篇文章主要介紹了IntelliJ IDEA打開多個Maven的module且相互調(diào)用代碼的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

###1、需求

1、IntelliJ IDEA打開多個項(xiàng)目
2、每個同學(xué)開發(fā)一個項(xiàng)目,相互之前獨(dú)立不影響
3、通過一個入口可以調(diào)用所有項(xiàng)目類、方法、屬性,達(dá)到同時開發(fā)且檢測代碼
4、dependency只需要寫一份,其余項(xiàng)目不用寫,便可全部依賴

###2、注意事項(xiàng)(非常重要)

6個坑:

1、<groupId>com.yh.bi</groupId>
項(xiàng)目中所有的groupId要一樣

2、避免循環(huán)依賴,導(dǎo)致程序報錯

3、<scope>provided</scope>
打包的服務(wù)器運(yùn)行時候需要provided,本機(jī)調(diào)試的時候,需要注釋
在一個maven項(xiàng)目中,如果存在編譯需要而發(fā)布不需要的jar包,可以用scope標(biāo)簽,值設(shè)為provided


4、項(xiàng)目、module建好之后需要添加Scala的框架支持

5、在yhProject中,可以統(tǒng)一對所有的module進(jìn)行清理、編譯、打包

6、要運(yùn)行依賴中的module,則必須要將module中的Jar包,打到maven中,需要使用install

下面,是我將所有module中的Jar打到Maven中的路徑:


###3、建立Project和建立module

1、只需要建立一個項(xiàng)目,其他項(xiàng)目由module建立,所有module且放在項(xiàng)目中。
2、本文項(xiàng)目為yhproject,其余都為module,分別是:mainEntrance、yhutils、yhapp、yhweb、yhgame

項(xiàng)目建立步鄹:

Module建立步鄹:

項(xiàng)目、所有module、部分module代碼展示:

###4、項(xiàng)目之前的依賴關(guān)系

###5、代碼展示

mainEntrance

package com.yh.bi.dag

package com.yh.bi.dag

/**
 * Created by yuhui on 2017/2/10.
 */
import java.time.{Duration, LocalDate}
import com.yh.bi._
import com.yh.bi.{UserAPP, UserGame, UserWEB}
import org.slf4j.LoggerFactory

import scala.collection.immutable.{ListMap, ListSet}

/**
 * Created by yuhui on 2016/8/25.
 * task --> Node --> DAG --> DAGExecutor
 */

case class Node[T](task: T, parent: T*) {
 override def toString: String = {
 s"$task(${parent.mkString(",")})"
 }
}

case class DAG[T](nodes: Node[T]*)

case class DAGExecutor[T](dag: DAG[T]) {
 private val LOG = LoggerFactory.getLogger(this.getClass)
 private val _nodes: Map[T, Seq[T]] = dag.nodes.map(node => (node.task, node.parent.filter(_ != null))).toMap
 private var _pending: Set[T] = ListSet()
 private var _fails = ListMap[T, String]()
 private var _success = Seq[T]()

 //判斷Node的task節(jié)點(diǎn)的父節(jié)點(diǎn)運(yùn)行狀態(tài)(flase ,true)
 private def getPending: Option[T] = {
 _pending.find { name =>
  val parents = _nodes(name)
  !parents.exists(name => !_success.contains(name))
 }
 }

 private def fail(name: T, message: String): Unit = {
 _pending -= name
 _fails += name -> message
 for (child <- _pending.filter(child => _nodes(child).contains(name))) {
  fail(child, s"依賴的任務(wù)無法執(zhí)行: $name")
 }
 }

 private def success(name: T): Unit = {
 _pending -= name
 _success = _success :+ name
 }

 def execute(func: T => Unit): Unit = {
 _pending = _nodes.keySet
 _fails = ListMap()
 _success = Seq()
 var running = true

 while (running) {
  val taskOpt = getPending
  if (taskOpt.nonEmpty) {
  val task = taskOpt.get
  val startMills = System.currentTimeMillis()
  LOG.info("start task {}", task)
  try {
   println("=============")
   func(task) //執(zhí)行executor方法
   println("+++++++++++++")
   val time = Duration.ofMillis(System.currentTimeMillis() - startMills)
   LOG.info(s"end task $task time=$time")
   success(task)
  } catch {
   case e: Throwable => fail(task, e.getMessage)
   LOG.error(e.getMessage, e)
   LOG.info(s"fail task $task")
  }
  } else {
  running = false
  }
 }

 for (name <- _success) {
  LOG.info(s"success task: $name")
 }
 for (name <- _fails) {
  LOG.info(s"fail task: ${name._1} - ${name._2}")
 }
 }
}

object DAG {
 val allSDKDAG = new DAG[Task](
 Node(UserAPP),
 Node(UserGame),
 Node(UserWEB)
 )

 def main(args: Array[String]): Unit = {
 DAGExecutor(allSDKDAG).execute { task =>task.executor("appkey": String, LocalDate.now(), LocalDate.now())}
 }
}

yhutils

package com.yh.bi

/**
 * Created by yuhui on 2017/2/10.
 */
import java.time.LocalDate
import org.apache.spark.sql.SQLContext
import org.slf4j.LoggerFactory

abstract class Executor extends Task with SQLContextAware {

 override def run(appkey: String, startDay: LocalDate, endDay: LocalDate)={}

}

trait SQLContextAware {
 implicit var ctx: SQLContext = _
}


abstract class Task {

 protected val LOG = LoggerFactory.getLogger(this.getClass)

 def executor(appkey: String, startDay: LocalDate, endDay: LocalDate): Unit

 def run(appkey: String, startDay: LocalDate, endDay: LocalDate): Unit = {
 executor(appkey, startDay, endDay)
 }

}

yhapp

package com.yh.bi

/**
 * Created by yuhui on 2017/2/10.
 */
import java.time.LocalDate

object UserAPP extends Executor{

 override def executor(appkey: String, startDay: LocalDate, endDay: LocalDate): Unit = {

 println("++++我的UserAPP的執(zhí)行過程++++")

 }

}

yhweb

package com.yh.bi

import java.time.LocalDate

object UserWEB extends Executor{

 override def executor(appkey: String, startDay: LocalDate, endDay: LocalDate): Unit = {

 println("++++我的UserWEB的執(zhí)行過程++++")

 }

}

yhgame

package com.yh.bi

/**
 * Created by yuhui on 2017/2/10.
 */
import java.time.LocalDate

object UserGame extends Executor{

 override def executor(appkey: String, startDay: LocalDate, endDay: LocalDate): Unit = {

 println("++++我的UserGame的執(zhí)行過程++++")

 }

}

###6、項(xiàng)目中POM依賴展示

yhproject中POM文件展示:

<?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>com.yh.bi</groupId>
 <artifactId>yhproject</artifactId>
 <packaging>pom</packaging>
 <version>1.0</version>

 <modules>
  <module>mainEntrance</module>
  <module>yhapp</module>
  <module>yhweb</module>
  <module>yhgame</module>
  <module>yhutils</module>
 </modules>
</project>

mainEntrance中POM文件展示:

<?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>
 <artifactId>mainEntrance</artifactId>
 <groupId>com.yh.bi</groupId>
 <version>1.0</version>

 <dependencies>
  <dependency>
   <artifactId>yhutils</artifactId>
   <groupId>com.yh.bi</groupId>
   <version>1.0</version>
   <!--<scope>provided</scope> //本機(jī)調(diào)試則注釋, 集群運(yùn)行則解開-->
  </dependency>

  <dependency>
   <artifactId>yhapp</artifactId>
   <groupId>com.yh.bi</groupId>
   <version>1.0</version>
   <!--<scope>provided</scope>-->
  </dependency>

  <dependency>
   <artifactId>yhgame</artifactId>
   <groupId>com.yh.bi</groupId>
   <version>1.0</version>
   <!--<scope>provided</scope>-->
  </dependency>

  <dependency>
   <artifactId>yhweb</artifactId>
   <groupId>com.yh.bi</groupId>
   <version>1.0</version>
   <!--<scope>provided</scope>-->
  </dependency>
 </dependencies>

 <build>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
     <source>1.8</source>
     <target>1.8</target>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4</version>
    <configuration>
     <filters>
      <filter>
       <artifact>*:*</artifact>
       <excludes>
        <exclude>**/log4j2.*</exclude>
        <exclude>META-INF/*.SF</exclude>
        <exclude>META-INF/*.DSA</exclude>
        <exclude>META-INF/*.RSA</exclude>
       </excludes>
      </filter>
     </filters>
     <!-- put your configurations here -->
    </configuration>
    <executions>
     <execution>
      <phase>package</phase>
      <goals>
       <goal>shade</goal>
      </goals>
      <configuration>
       <outputFile>${project.build.directory}/${project.artifactId}.jar
       </outputFile>
      </configuration>
     </execution>
    </executions>
   </plugin>

  </plugins>

  <sourceDirectory>src/main/scala</sourceDirectory>
  <resources>
   <resource>
    <directory>${basedir}/src/main/resources</directory>
    <includes>
     <include>**/*</include>
    </includes>
   </resource>
  </resources>

 </build>


</project>

yhutils中POM文件展示:

<?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">
 <parent>
  <artifactId>yhproject</artifactId>
  <groupId>com.yh.bi</groupId>
  <version>1.0</version>
 </parent>

 <modelVersion>4.0.0</modelVersion>
 <artifactId>yhutils</artifactId>

 <dependencies>
  <dependency>
   <groupId>org.apache.spark</groupId>
   <artifactId>spark-hive_2.11</artifactId>
   <version>1.6.1</version>
  </dependency>
 </dependencies>

 <build>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
     <source>1.8</source>
     <target>1.8</target>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4</version>
    <configuration>
     <filters>
      <filter>
       <artifact>*:*</artifact>
       <excludes>
        <exclude>**/log4j2.*</exclude>
        <exclude>META-INF/*.SF</exclude>
        <exclude>META-INF/*.DSA</exclude>
        <exclude>META-INF/*.RSA</exclude>
       </excludes>
      </filter>
     </filters>
     <!-- put your configurations here -->
    </configuration>
    <executions>
     <execution>
      <phase>package</phase>
      <goals>
       <goal>shade</goal>
      </goals>
      <configuration>
       <outputFile>${project.build.directory}/${project.artifactId}.jar
       </outputFile>
      </configuration>
     </execution>
    </executions>
   </plugin>

  </plugins>

  <sourceDirectory>src/main/scala</sourceDirectory>
  <resources>
   <resource>
    <directory>${basedir}/src/main/resources</directory>
    <includes>
     <include>**/*</include>
    </includes>
   </resource>
  </resources>

 </build>
</project>

yhapp中POM文件展示:

<?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>com.yh.bi</groupId>
 <artifactId>yhapp</artifactId>
 <version>1.0</version>

 <dependencies>
  <dependency>
   <artifactId>yhutils</artifactId>
   <groupId>com.yh.bi</groupId>
   <version>1.0</version>
   <scope>provided</scope>
  </dependency>
 </dependencies>
 <build>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
     <source>1.8</source>
     <target>1.8</target>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4</version>
    <configuration>
     <filters>
      <filter>
       <artifact>*:*</artifact>
       <excludes>
        <exclude>**/log4j2.*</exclude>
        <exclude>META-INF/*.SF</exclude>
        <exclude>META-INF/*.DSA</exclude>
        <exclude>META-INF/*.RSA</exclude>
       </excludes>
      </filter>
     </filters>
     <!-- put your configurations here -->
    </configuration>
    <executions>
     <execution>
      <phase>package</phase>
      <goals>
       <goal>shade</goal>
      </goals>
      <configuration>
       <outputFile>${project.build.directory}/${project.artifactId}.jar
       </outputFile>
      </configuration>
     </execution>
    </executions>
   </plugin>

  </plugins>

  <sourceDirectory>src/main/scala</sourceDirectory>
  <resources>
   <resource>
    <directory>${basedir}/src/main/resources</directory>
    <includes>
     <include>**/*</include>
    </includes>
   </resource>
  </resources>

 </build>

</project>

yhweb中POM文件展示:

<?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>com.yh.bi</groupId>
 <artifactId>yhweb</artifactId>
 <version>1.0</version>

 <dependencies>
  <dependency>
   <artifactId>yhutils</artifactId>
   <groupId>com.yh.bi</groupId>
   <version>1.0</version>
   <scope>provided</scope>
  </dependency>
 </dependencies>
 <build>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
     <source>1.8</source>
     <target>1.8</target>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4</version>
    <configuration>
     <filters>
      <filter>
       <artifact>*:*</artifact>
       <excludes>
        <exclude>**/log4j2.*</exclude>
        <exclude>META-INF/*.SF</exclude>
        <exclude>META-INF/*.DSA</exclude>
        <exclude>META-INF/*.RSA</exclude>
       </excludes>
      </filter>
     </filters>
     <!-- put your configurations here -->
    </configuration>
    <executions>
     <execution>
      <phase>package</phase>
      <goals>
       <goal>shade</goal>
      </goals>
      <configuration>
       <outputFile>${project.build.directory}/${project.artifactId}.jar
       </outputFile>
      </configuration>
     </execution>
    </executions>
   </plugin>

  </plugins>

  <sourceDirectory>src/main/scala</sourceDirectory>
  <resources>
   <resource>
    <directory>${basedir}/src/main/resources</directory>
    <includes>
     <include>**/*</include>
    </includes>
   </resource>
  </resources>

 </build>

</project>

yhgame中POM文件展示:

<?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>com.yh.bi</groupId>
 <artifactId>yhgame</artifactId>
 <version>1.0</version>

 <dependencies>
  <dependency>
   <artifactId>yhutils</artifactId>
   <groupId>com.yh.bi</groupId>
   <version>1.0</version>
   <scope>provided</scope>
  </dependency>
 </dependencies>
  <build>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
     <source>1.8</source>
     <target>1.8</target>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4</version>
    <configuration>
     <filters>
      <filter>
       <artifact>*:*</artifact>
       <excludes>
        <exclude>**/log4j2.*</exclude>
        <exclude>META-INF/*.SF</exclude>
        <exclude>META-INF/*.DSA</exclude>
        <exclude>META-INF/*.RSA</exclude>
       </excludes>
      </filter>
     </filters>
     <!-- put your configurations here -->
    </configuration>
    <executions>
     <execution>
      <phase>package</phase>
      <goals>
       <goal>shade</goal>
      </goals>
      <configuration>
       <outputFile>${project.build.directory}/${project.artifactId}.jar
       </outputFile>
      </configuration>
     </execution>
    </executions>
   </plugin>

  </plugins>

  <sourceDirectory>src/main/scala</sourceDirectory>
  <resources>
   <resource>
    <directory>${basedir}/src/main/resources</directory>
    <includes>
     <include>**/*</include>
    </includes>
   </resource>
  </resources>

 </build>

</project>

###7、運(yùn)行結(jié)果展示

注意:我在mainEntrance執(zhí)行DAG中的main文件,可以調(diào)用且執(zhí)行了yhutils、yhapp、yhweb、yhgame中的代碼

###8、如果建立Java 的module

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Maven使用集成測試的示例代碼

    Maven使用集成測試的示例代碼

    本文介紹了在Maven項(xiàng)目中使用maven-failsafe-plugin插件進(jìn)行集成測試,步驟包括添加測試依賴、編寫集成測試類、配置插件、運(yùn)行測試以及查看和分析測試結(jié)果,感興趣的可以了解一下
    2024-11-11
  • SpringMVC+MyBatis 事務(wù)管理(實(shí)例)

    SpringMVC+MyBatis 事務(wù)管理(實(shí)例)

    本文先分析編程式注解事務(wù)和基于注解的聲明式事務(wù)。對SpringMVC+MyBatis 事務(wù)管理的相關(guān)知識感興趣的朋友一起學(xué)習(xí)吧
    2017-08-08
  • Java 集合框架之List 的使用(附小游戲練習(xí))

    Java 集合框架之List 的使用(附小游戲練習(xí))

    這篇文章主要介紹Java 集合框架中List 的使用,下面文章將圍繞Java 集合框架中List 的使用展開話題,并附上一些小游戲練習(xí),需要的朋友可以參考一下
    2021-10-10
  • java面向?qū)ο蠡A(chǔ)_final詳細(xì)介紹

    java面向?qū)ο蠡A(chǔ)_final詳細(xì)介紹

    本文將詳細(xì)介紹java final 對象的使用,需要了解更多的朋友可以參考下
    2012-11-11
  • 如何利用Spring把元素解析成BeanDefinition對象

    如何利用Spring把元素解析成BeanDefinition對象

    這篇文章主要介紹了如何利用Spring把元素解析成BeanDefinition對象,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下
    2022-08-08
  • Java內(nèi)部類詳解

    Java內(nèi)部類詳解

    內(nèi)部類在 Java 里面算是非常常見的一個功能了,在日常開發(fā)中我們肯定多多少少都用過,這里總結(jié)一下關(guān)于 Java 中內(nèi)部類的相關(guān)知識點(diǎn)和一些使用內(nèi)部類時需要注意的點(diǎn)。
    2020-02-02
  • Spring Cloud 如何保證微服務(wù)內(nèi)安全

    Spring Cloud 如何保證微服務(wù)內(nèi)安全

    這篇文章主要介紹了Spring Cloud 如何保證微服務(wù)內(nèi)安全的操作,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-07-07
  • java裁剪圖片并保存的示例分享

    java裁剪圖片并保存的示例分享

    在這篇文章中我們將學(xué)習(xí)如何用Java 對圖像進(jìn)行剪裁并將剪裁出來的部分單獨(dú)保存到文件中
    2014-01-01
  • Java Stream流之GroupBy的使用方式

    Java Stream流之GroupBy的使用方式

    本教程將詳細(xì)介紹如何在 Java 中使用 Stream 流的 group by 方法,包括基本用法和一些常見的實(shí)際應(yīng)用場景,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-04-04
  • Spring Boot兩種配置文件properties和yml區(qū)別

    Spring Boot兩種配置文件properties和yml區(qū)別

    這篇文章主要為大家介紹了java面試中常見問到的Spring Boot兩種配置文件properties和yml區(qū)別解答,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-07-07

最新評論

鄱阳县| 江源县| 嘉禾县| 香河县| 大方县| 武清区| 三河市| 重庆市| 林周县| 资中县| 绥阳县| 富顺县| 察隅县| 永年县| 开平市| 利津县| 蒙阴县| 博白县| 老河口市| 瓮安县| 浪卡子县| 玉山县| 广安市| 彭山县| 丽江市| 鹿邑县| 平乡县| 博罗县| 诸城市| 许昌市| 彭州市| 成都市| 于田县| 洛南县| 安塞县| 黄大仙区| 姚安县| 扎赉特旗| 安福县| 桓仁| 汾西县|