1. 程式人生 > >如何配置idea使一個視窗包含多個工程

如何配置idea使一個視窗包含多個工程

 你是否在煩惱為什麼idea不能像eclipse那樣,一個視窗含任意個工程?那麼看這篇文章就對了。只要輕鬆的幾行配置即可解決問題。
 
建立一個目錄 mutil_projects
將hello-server,hello-web,helloservice 等工程clone到該目錄下

新建一個pom.xml檔案,將三個工程作為module加入這個工程

<?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.hello.all</groupId>
 <artifactId>all</artifactId>
 <packaging>pom</packaging>
 <version>1.0-SNAPSHOT</version>
 <modules>
 <module>hello-web</module>
 <module>hello-server</module>
 <module>helloservice</module>
 </modules>
</project>

開啟idea,選擇mutil_projects目錄,匯入maven專案.

,如果非maven專案可以在專案下新建一個pom.xml,內容填寫類似:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.hello.all</groupId>
    <artifactId>all</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <groupId>com.hello</groupId>
  <artifactId>hello-server</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>hello-server Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>hello-server</finalName>
  </build>
</project>

重新整理


目錄結構:mutil_projects下面包含三個獨立的maven專案


如何將一個靜態資源專案加入?

1、加入前:


2、新建pom.xml,並初始化內容為

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.hello</groupId>
  <artifactId>hello-static</artifactId>
  <version>1.0-SNAPSHOT</version>
</project>


3、在根pom下新增hello-static作為一個子模組


4、重新整理一下maven專案


done!