我的项目结构看起来像
project/pom.xml
/services/pom.xml
src/main/scala/(scala class here)
src/main/resources/application.conf
/manager/pom.xml
src/main/scala/(scala class here)
src/main/resources/manager.conf
services/pom.xml
看起来像
<properties>
<akka-http.version>1.0</akka-http.version>
</properties>
<dependencies>
<dependency>
<groupId>com.shn.enterpriseconnector</groupId>
<artifactId>manager</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-experimental_2.11</artifactId>
<version>${akka-http.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-spray-json-experimental_2.11</artifactId>
<version>${akka-http.version}</version>
</dependency>
</dependencies>
但是当我做mvn clean install
并检查jar的内容时,我看到了
$ jar -tvf service/target/service-1.0-SNAPSHOT.jar
0 Thu Jul 30 09:45:12 PDT 2015 META-INF/
130 Thu Jul 30 09:45:10 PDT 2015 META-INF/MANIFEST.MF
629 Thu Jul 30 09:45:12 PDT 2015 application.conf
0 Thu Jul 30 09:45:12 PDT 2015 META-INF/maven/
0 Thu Jul 30 09:45:12 PDT 2015 META-INF/maven/com.shn.enterpriseconnector/
0 Thu Jul 30 09:45:12 PDT 2015 META-INF/maven/com.shn.enterpriseconnector/service/
1284 Thu Jul 30 09:38:30 PDT 2015 META-INF/maven/com.shn.enterpriseconnector/service/pom.xml
126 Thu Jul 30 09:45:12 PDT 2015 META-INF/maven/com.shn.enterpriseconnector/service/pom.properties
在project.pom.xml
,我有
<properties>
<scala-library.version>2.11.7</scala-library.version>
<akka.version>2.3.12</akka.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala-library.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>${akka.version}</version>
</dependency>
</dependencies>
<build>
<defaultGoal>clean install</defaultGoal>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
</plugin>
</plugins>
</build>
但我没有看到任何东西,没有我的项目类,也没有任何依赖类
我错过了什么?
答案 0 :(得分:1)
我花了很多时间阅读并尝试了几件事,并且project/pom.xml
更改对我来说效果很好
<build>
<defaultGoal>clean install</defaultGoal>
<sourceDirectory>src/main/scala</sourceDirectory>
<plugins>
<plugin>
<!-- see http://davidb.github.com/scala-maven-plugin -->
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>EnterpriseConnectorServer</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
答案 1 :(得分:1)
至少,这应该有效:
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>