我有一个带有3个spring boot子模块的spring boot项目:


mxm-suv-dao
mxm-suv-batch
mxm-suv-ws


dao子模块由batch和ws使用。

在本地(使用Eclipse),我可以安装/打包或启动这些模块,一切正常。

但是,当我尝试使用java -jar在服务器中启动批处理时,会获得“ java.lang.ClassNotFoundException:com.at.mxm.suv.dao.domain.Report”。

dao pom.xml:

<parent>
    <groupId>com.at.mxm</groupId>
    <artifactId>mxm-suv</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>mxm-suv-dao</artifactId>
<name>mxm-suv-dao</name>

<properties>
    <start-class>com.at.mxm.suv.dao.DataAccessApplication</start-class>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>

</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                    <configuration>
                        <classifier>exec</classifier>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>


批处理pom.xml:

<parent>
    <groupId>com.at.mxm</groupId>
    <artifactId>mxm-suv</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>mxm-suv-batch</artifactId>
<name>mxm-suv-batch</name>
<properties>
    <start-class>com.at.mxm.suv.batch.BatchApplication</start-class>
</properties>
<dependencies>
    <dependency>
        <groupId>com.at.mxm</groupId>
        <artifactId>mxm-suv-dao</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-batch</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-quartz</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>


BatchApplication.java:

@ComponentScan(basePackages = "com.at.mxm.suv.dao.*,com.at.mxm.suv.batch.*")
@SpringBootApplication
@EnableBatchProcessing
@EnableScheduling
public class BatchApplication {

  public static void main(String[] args) throws Exception {
      SpringApplication.run(BatchApplication.class, args);
  }
}


有什么想法可能导致这种情况吗?

最佳答案

请参阅此git存储库。我已经制作了5个模块。

07-24 18:27