Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mvn clean编译包在构建中不包括src/main/java文件_Java_Maven - Fatal编程技术网

mvn clean编译包在构建中不包括src/main/java文件

mvn clean编译包在构建中不包括src/main/java文件,java,maven,Java,Maven,我以前使用maven生成过jar文件,从未遇到过我当前项目面临的这个奇怪问题 这是一个spring项目,它有以下pom.xml: <?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生成过jar文件,从未遇到过我当前项目面临的这个奇怪问题

这是一个spring项目,它有以下
pom.xml

<?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.example</groupId>
    <artifactId>SAMPLE_AOP</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>SAMPLE_AOP</name>
    <description>Spring boot project using AspectJ library for adding behavior without modifying existing caps backend micro-services.</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <log4j.version>1.2.17</log4j.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
        </dependency>
    </dependencies>

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


            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <!-- Full configuration to configure each friendly parameters -->
                <configuration>
                    <complianceLevel>1.8</complianceLevel>
                    <source>1.8</source>
                    <target>1.8</target>
                    <showWeaveInfo>true</showWeaveInfo>
                    <verbose>true</verbose>
                    <Xlint>ignore</Xlint>
                    <encoding>UTF-8 </encoding>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <!-- use this goal to weave all your main classes -->
                            <goal>compile</goal>
                            <!-- use this goal to weave all your test classes -->
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


</project>
它只包含一些其他依赖项,而不包含
src/main/java
下的实际代码

请忽略pom.xml中包含依赖项的jar,我不希望依赖项打包到我的jar中。我不确定我在这里遗漏了什么,你能指出吗

另外,我检查了项目的构建路径,我可以看到src/main/java被识别为源文件夹,并且我在pom.xml中的
标记中也明确提到了它

Maven输出:

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.example:SAMPLE_AOP:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:aspectj-maven-plugin is missing. @ line 71, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] ----------------------< com.example:SAMPLE_AOP >----------------------
[INFO] Building SAMPLE_AOP 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ SAMPLE_AOP ---
[INFO] Deleting C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\target
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ SAMPLE_AOP ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ SAMPLE_AOP ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\target\classes
[INFO] /C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE_AOP/src/main/java/com.sample/AnnotationHelper.java: C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\src\main\java\com.sample\AnnotationHelper.java uses unchecked or unsafe operations.
[INFO] /C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE_AOP/src/main/java/com.sample/AnnotationHelper.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- aspectj-maven-plugin:1.11:compile (default) @ SAMPLE_AOP ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[INFO] Join point 'method-execution(void com.sample.Application.testing())' in Type 'com.sample.Application' (Application.java:13) advised by around advice from 'com.sample.aspect.LoggingAspect' (LoggingAspect.java:43)
[INFO] Join point 'method-execution(void com.sample.Application.testString())' in Type 'com.sample.Application' (Application.java:20) advised by around advice from 'com.sample.aspect.LoggingAspect' (LoggingAspect.java:43)
[INFO] Join point 'method-call(void com.sample.Application.testing())' in Type 'com.sample.Application' (Application.java:27) advised by around advice from 'com.sample.aspect.LoggingAspect' (LoggingAspect.java:43)
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ SAMPLE_AOP ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ SAMPLE_AOP ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\target\classes
[INFO] /C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE_AOP/src/main/java/com.sample/AnnotationHelper.java: C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\src\main\java\com.sample\AnnotationHelper.java uses unchecked or unsafe operations.
[INFO] /C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE_AOP/src/main/java/com.sample/AnnotationHelper.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- aspectj-maven-plugin:1.11:compile (default) @ SAMPLE_AOP ---
[INFO] No modifications found skipping aspectJ compile
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ SAMPLE_AOP ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ SAMPLE_AOP ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- aspectj-maven-plugin:1.11:test-compile (default) @ SAMPLE_AOP ---
[WARNING] No sources found skipping aspectJ compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ SAMPLE_AOP ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ SAMPLE_AOP ---
[INFO] Building jar: C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\target\SAMPLE_AOP-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.3.RELEASE:repackage (default) @ SAMPLE_AOP ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:04 min
[INFO] Finished at: 2018-08-05T21:48:14+05:30
[INFO] ------------------------------------------------------------------------
[INFO]正在扫描项目。。。
[警告]
[警告]为com构建有效模型时遇到一些问题。示例:SAMPLE_AOP:jar:0.0.1-SNAPSHOT
[警告].codehaus.mojo的'build.plugins.plugin.version':缺少aspectj maven插件。@第71行第12列
[警告]
[警告]强烈建议修复这些问题,因为它们会威胁到构建的稳定性。
[警告]
[警告]出于这个原因,未来的Maven版本可能不再支持构建这种格式错误的项目。
[警告]
[信息]
[信息]-----------------------------------------------
[信息]建筑示例\u AOP 0.0.1-快照
[信息]------------------------------------[jar]---------------------------------
[信息]
[信息]---maven clean插件:3.0.0:clean(默认清洁)@SAMPLE\u AOP---
[信息]删除C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE\u AOP\target
[信息]
[信息]---maven资源插件:3.0.1:资源(默认资源)@SAMPLE\u AOP---
[信息]使用“UTF-8”编码复制筛选的资源。
[信息]正在复制1个资源
[信息]正在复制1个资源
[信息]
[信息]---maven编译器插件:3.7.0:compile(默认编译)@SAMPLE\u AOP---
[信息]检测到更改-重新编译模块!
[信息]将7个源文件编译为C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE\u AOP\target\classes
[INFO]/C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE\u AOP/src/main/java/com.SAMPLE/AnnotationHelper.java:C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE\AOP\src\main\java\com.SAMPLE\AnnotationHelper.java使用未经检查或不安全的操作。
[INFO]/C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE\u AOP/src/main/java/com.SAMPLE/AnnotationHelper.java:使用-Xlint重新编译:未选中以获取详细信息。
[信息]
[信息]——aspectj maven插件:1.11:compile(默认)@SAMPLE\u AOP---
[信息]显示以下类型消息的AJC消息详细信息:[错误、警告、失败]
[INFO]类型“com.sample.Application”(Application.java:13)中的连接点“method execution(void com.sample.Application.testing())”,由来自“com.sample.aspect.loggingapect”(loggingapect.java:43)的around建议建议
[INFO]类型“com.sample.Application”(Application.java:20)中的连接点“method execution(void com.sample.Application.testString())”,由来自“com.sample.aspect.loggingapect”(loggingapect.java:43)的around建议建议
[INFO]类型“com.sample.Application”(Application.java:27)中的连接点“方法调用(void com.sample.Application.testing())”,由来自“com.sample.aspect.LoggingAspect”(LoggingAspect.java:43)的around建议提供
[信息]
[信息]---maven资源插件:3.0.1:资源(默认资源)@SAMPLE\u AOP---
[信息]使用“UTF-8”编码复制筛选的资源。
[信息]正在复制1个资源
[信息]正在复制1个资源
[信息]
[信息]---maven编译器插件:3.7.0:compile(默认编译)@SAMPLE\u AOP---
[信息]检测到更改-重新编译模块!
[信息]将7个源文件编译为C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE\u AOP\target\classes
[INFO]/C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE\u AOP/src/main/java/com.SAMPLE/AnnotationHelper.java:C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE\AOP\src\main\java\com.SAMPLE\AnnotationHelper.java使用未经检查或不安全的操作。
[INFO]/C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE\u AOP/src/main/java/com.SAMPLE/AnnotationHelper.java:使用-Xlint重新编译:未选中以获取详细信息。
[信息]
[信息]——aspectj maven插件:1.11:compile(默认)@SAMPLE\u AOP---
[信息]没有发现跳过aspectJ编译的修改
[信息]
[信息]---maven资源插件:3.0.1:testResources(默认testResources)@SAMPLE\u AOP---
[信息]使用“UTF-8”编码复制筛选的资源。
[信息]跳过不存在的资源目录C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE\u AOP\src\test\resources
[信息]
[信息]---maven编译器插件:3.7.0:testCompile(默认testCompile)@SAMPLE\u AOP---
[信息]无需编译-所有类都是最新的
[信息]
[信息]——aspectj maven插件:1.11:测试编译(默认)@SAMPLE\u AOP---
[警告]未找到跳过aspectJ编译的源
[信息]
[信息]---maven surefire插件:2.21.0:test(默认测试)@SAMPLE\u AOP---
[信息]没有要运行的测试。
[信息]
[信息]---maven jar插件:3.0.2:jar(默认jar)@SAMPLE\u AOP---
[信息]构建jar:C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE\u AOP\target\SAMPLE\u AOP-0.0.1-SNAPSHOT.jar
[信息]
[信息]---spring boot maven插件:2.0.3.版本:重新打包(默认)@SAMPLE\u AOP---
[信息]------------------------------------------------------------------------
[信息]建立成功
[信息]------------------------------------------------------------------------
[信息]总时间:01:04分钟
[信息]完成时间:2018-08-05T21:48:14+05:30
[信息]------------------------------------------------------------------------

您的预期输出是什么?此构建产生了什么?但是,sourceDirectory通常是src/main/java,您在pom.xml中将其切换为src。您还可以将jar与依赖项和spring boot重新打包一起使用,这两种方法都构建了一个uber jar。不
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.example:SAMPLE_AOP:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:aspectj-maven-plugin is missing. @ line 71, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] ----------------------< com.example:SAMPLE_AOP >----------------------
[INFO] Building SAMPLE_AOP 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ SAMPLE_AOP ---
[INFO] Deleting C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\target
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ SAMPLE_AOP ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ SAMPLE_AOP ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\target\classes
[INFO] /C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE_AOP/src/main/java/com.sample/AnnotationHelper.java: C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\src\main\java\com.sample\AnnotationHelper.java uses unchecked or unsafe operations.
[INFO] /C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE_AOP/src/main/java/com.sample/AnnotationHelper.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- aspectj-maven-plugin:1.11:compile (default) @ SAMPLE_AOP ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[INFO] Join point 'method-execution(void com.sample.Application.testing())' in Type 'com.sample.Application' (Application.java:13) advised by around advice from 'com.sample.aspect.LoggingAspect' (LoggingAspect.java:43)
[INFO] Join point 'method-execution(void com.sample.Application.testString())' in Type 'com.sample.Application' (Application.java:20) advised by around advice from 'com.sample.aspect.LoggingAspect' (LoggingAspect.java:43)
[INFO] Join point 'method-call(void com.sample.Application.testing())' in Type 'com.sample.Application' (Application.java:27) advised by around advice from 'com.sample.aspect.LoggingAspect' (LoggingAspect.java:43)
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ SAMPLE_AOP ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ SAMPLE_AOP ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\target\classes
[INFO] /C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE_AOP/src/main/java/com.sample/AnnotationHelper.java: C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\src\main\java\com.sample\AnnotationHelper.java uses unchecked or unsafe operations.
[INFO] /C:/Users/user/Documents/workspace-sts-3.9.5.RELEASE/SAMPLE_AOP/src/main/java/com.sample/AnnotationHelper.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- aspectj-maven-plugin:1.11:compile (default) @ SAMPLE_AOP ---
[INFO] No modifications found skipping aspectJ compile
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ SAMPLE_AOP ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ SAMPLE_AOP ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- aspectj-maven-plugin:1.11:test-compile (default) @ SAMPLE_AOP ---
[WARNING] No sources found skipping aspectJ compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ SAMPLE_AOP ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ SAMPLE_AOP ---
[INFO] Building jar: C:\Users\user\Documents\workspace-sts-3.9.5.RELEASE\SAMPLE_AOP\target\SAMPLE_AOP-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.3.RELEASE:repackage (default) @ SAMPLE_AOP ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:04 min
[INFO] Finished at: 2018-08-05T21:48:14+05:30
[INFO] ------------------------------------------------------------------------