maven不打包编译的源文件

vuktfyat  于 2022-11-22  发布在  Maven
关注(0)|答案(1)|浏览(272)

I have the following in my pom.xml

<build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>17</source>
                <target>17</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/main/java</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

The only classes found in the 0.0.1-SNAPSHOT.jar are from org.springframework.boot.loader package. None of the class files compiled from my source files is there. Below is the output of maven install:
INFO] --------------------< com.stocktrader:stock-trader
-------------------- [INFO] Building stock-trader 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- build-helper-maven-plugin:3.0.0:add-source (default) @ stock-trader --- [INFO] Source directory: C:\Users\kannanj\IdeaProjects\ibkr\src\main\java added. [INFO] [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ stock-trader --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Using 'UTF-8' encoding to copy filtered properties files. [INFO] Copying 1 resource [INFO] Copying 3 resources [INFO] [INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ stock-trader --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ stock-trader --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Using 'UTF-8' encoding to copy filtered properties files. [INFO] skip non existing resourceDirectory C:\Users\kannanj\IdeaProjects\ibkr\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ stock-trader --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ stock-trader --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) @ stock-trader --- [INFO] Building jar: C:\Users\kannanj\IdeaProjects\ibkr\target\stock-trader-0.0.1-SNAPSHOT.jar [INFO] [INFO] --- spring-boot-maven-plugin:2.7.0:repackage (repackage) @ stock-trader --- [INFO] Replacing main artifact with repackaged archive [INFO] [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ stock-trader --- [INFO] Installing C:\Users\kannanj\IdeaProjects\ibkr\target\stock-trader-0.0.1-SNAPSHOT.jar to C:\Users\kannanj.m2\repository\com\stocktrader\stock-trader\0.0.1-SNAPSHOT\stock-trader-0.0.1-SNAPSHOT.jar [INFO] Installing C:\Users\kannanj\IdeaProjects\ibkr\pom.xml to C:\Users\kannanj.m2\repository\com\stocktrader\stock-trader\0.0.1-SNAPSHOT\stock-trader-0.0.1-SNAPSHOT.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS
Please help before I shoot myself.

polhcujo

polhcujo1#

如果要在另一个项目中使用某些公用零件,有两种可能的解决方案。

  • 首先做一个多模块的构建,并把公共部分和其他部分分开。公共部分将是一个简单的jar(也可能有一些Spring支持)
  • 创建一个完整的独立项目并使用它。

相关问题