親POMを使用せずに、ローカルに - 私は別のプロジェクトで依存関係として1つのSBプロジェクトを使用することを探しています。私は、親のポンポンを使用して、モジュールを指定する前にこれを行っているが、私はレポと親ポンポンなしで同じことを達成する必要まで分割で探しています。
私はこれを行う方法を概説し、いくつかのSOの記事を発見した、それらのどれも私のために働くように見えるん。彼らは、すべての関与mvn install
それは地元のレポで利用できるように、アーティファクトをする。そして、それはそうでないまで、私のために働くようです。
注:私は、企業環境で働いていますし、私たちの内部ネクサスレポにこれらのjarファイルを展開する計画を行う、しかし、私が最初にこのルートダウンダイビングの前に地域の発展を把握したいと思います。
私のセットアップは、(異なる名前で)2つの空のstart.spring.ioプロジェクトです。
.
├── test-application
│ ├── pom.xml
│ └── src
│ └── main
│ ├── java
│ │ └── com
│ │ └── example
│ │ └── testapplication
│ │ ├── TestApplication.java
│ │ └── TestClientConfig.java
│ └── resources
│ └── application.properties
│
└── test-client
├── pom.xml
└── src
└── main
├── java
│ └── com
│ └── example
│ └── testclient
│ ├── TestClient.java
│ └── TestClientApplication.java
└── resources
└── application.properties
あるプロジェクトでは、test-client
私は、新しいクラスを定義します
// TestClient.java
public class TestClient {
private String value;
public TestClient(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
私は私のコンシューマアプリケーションでのBeanになりますただ、いくつかの基本的なテストクラス。
次に、私が実行しmvn clean install
、それは私の中でだことを確認し.m2/repository
たフォルダ
そして今で test-application
//pom.xml
<dependency>
<groupId>com.example</groupId>
<artifactId>test-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
IntelliJの自動インポートし、すべてのルックスの罰金、赤なし。
次に、新しいファイルの内部にTestClientConfig.java
、私は私のクライアントの実装を開始:
IntellJは、依存から新しいクラスをピックアップし、それらを示唆しています。私はインポートしようとすると、しかし、物事は、あまりにもうまく動作しません。
これは、完全なパッケージ名をインポートし、それを認識しません。
And I can't add an import statement.
So I am stuck at this point. I have tried finessing some settings in IntelliJ to include the compiled jar as a library or to add a module but nothing really seemed to work fully and those options seemed kind of hacky.
Here's a link to the zip: https://drive.google.com/open?id=13XGVzICO_QHn_ihM7NFtK3GobAxeqLYf
With Maven modules IntelliJ IDEA will resolve the dependencies from sources instead of jars. With your setup the dependencies are resolved from jars.
The .class
files need to be in the root of the jar instead of BOOT-INF
if you want to depend on this jar in the other projects. The classes are in BOOT-INF
since you are using spring-boot-loader
application which builds the executable jar.
この文書では、問題を回避する方法について説明します。
別のプロジェクトで共有クラスにするために、取るべき最善のアプローチは、それらに依存しているすべてのモジュールの依存関係作り、その後、共有クラスを含む別のjarファイルを作成することです。
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
これは、二つの瓶、実行可能なjarファイルとして接尾幹部との1、私たちは他のプロジェクトに含めることができることが、より一般的なjarファイルとして別のものを作成します。