Maven项目Build path ->No action available 解决方案

本文介绍如何通过编辑项目的.project文件来正确配置Eclipse中的Maven项目,包括添加必要的构建命令和性质,确保项目能够顺利构建。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

找到项目的.project文件,添加的内容如下:
     <buildSpec>
          <buildCommand>
               <name>org.eclipse.jdt.core.javabuilder</name>
               <arguments>
               </arguments>
          </buildCommand>
          <buildCommand>
               <name>org.eclipse.m2e.core.maven2Builder</name>
               <arguments>
               </arguments>
          </buildCommand>
     </buildSpec>
     <natures>
          <nature>org.eclipse.jdt.core.javanature</nature>
          <nature>org.eclipse.m2e.core.maven2Nature</nature>
     </natures>



<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <!--项目坐标--> <parent> <!--统一管理依赖版本--> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.7.18</version> <relativePath/> </parent> <!--项目定位标识--> <groupId>com.ChangGuangSatellite</groupId> <artifactId>intelligence_finance_java</artifactId> <version>0.0.1-SNAPSHOT</version> <name>intelligence_finance_java</name> <description>confirmationSystem</description> <!--JDK版本--> <properties> <java.version>1.8</java.version> </properties> <!--项目依赖--> <dependencies> <!--web依赖包,web应用必备,内置tomcat--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- pageHelper 分页插件 --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.4.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <dependency> <groupId>jakarta.persistence</groupId> <artifactId>jakarta.persistence-api</artifactId> <version>3.1.0</version> </dependency> <!--springboot单元测试--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!--springboot热部署--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <!--aop依赖包--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> <!--mysql驱动--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.29</version> </dependency> <!--mongodb驱动--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> <!-- mybatis-plus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.5.7</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.15</version> </dependency> <!--lombok简化实体类--> <!--官方文档:https://projectlombok.org/ --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.12</version> </dependency> <!-- JDBC --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <!--阿里巴巴json解析库--> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.54</version> </dependency> <!--JWT token生成校验工具--> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt</artifactId> <version>0.9.1</version> </dependency> <!--swagger增强工具依赖包,方便生成接口文档--> <!--官方文档:https://doc.xiaominfo.com/knife4j/documentation/ --> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-boot-starter</artifactId> <version>2.0.1</version> </dependency> <!--Hutool工具包--> <!--官方文档:https://www.hutool.cn/docs/#/ --> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.6.7</version> </dependency> <!--spring scurity 登录验证--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <!--redis依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <!-- excel插件依赖--> <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <version>2.1.6</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.12.0</version> </dependency> <!-- 用来开启事务使用 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.2.6.RELEASE</version> <configuration> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> </configuration> </plugin> <!-- 打包跳过单元测试--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> <!-- xml文件--> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> </build> </project> 2025-07-15 16:47:16.884 ERROR 77564 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: An attempt was made to call a method that does not exist. The attempt was made from the following location: com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.parse(MybatisMapperAnnotationBuilder.java:122) The following method did not exist: org.apache.ibatis.session.Configuration.parsePendingMethods(Z)V The calling method's class, com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder, was loaded from the following location: jar:file:/D:/Develop/software/maven-repository/com/baomidou/mybatis-plus-core/3.5.9/mybatis-plus-core-3.5.9.jar!/com/baomidou/mybatisplus/core/MybatisMapperAnnotationBuilder.class The called method's class, org.apache.ibatis.session.Configuration, is available from the following locations: jar:file:/D:/Develop/software/maven-repository/org/mybatis/mybatis/3.5.15/mybatis-3.5.15.jar!/org/apache/ibatis/session/Configuration.class The called method's class hierarchy was loaded from the following locations: org.apache.ibatis.session.Configuration: file:/D:/Develop/software/maven-repository/org/mybatis/mybatis/3.5.15/mybatis-3.5.15.jar Action: Correct the classpath of your application so that it contains compatible versions of the classes com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder and org.apache.ibatis.session.Configuration Process finished with exit code 1 报错分析
07-16
翻译: Of course. After reviewing your Gradle files, it's clear the main problem is not a single error but a mix of structural issues, outdated practices, and critical typos. Your build script merges settings that should be in separate files and uses fragile methods that will cause constant problems. Here is a breakdown of the issues and a step-by-step guide to fix them. ----- ### \#\# 1. Critical Errors That Will Break the Build These issues need to be fixed first, as they will prevent Gradle from running correctly. #### **A. Typo in `targetSdk`** In your module's `build.gradle`, you have a typo. * **Problem:** `targetsdk 34` * **Fix:** It should be `targetSdk` (with a capital 'S'). <!-- end list --> ```groovy // In your module's build.gradle defaultConfig { minSdk 29 targetSdk 34 // FIX: Was 'targetsdk' } ``` #### **B. Typo in JaCoCo Configuration** In your `createOfflineTestCoverageReport` task, you have a typo in the word "configurations". * **Problem:** `classpath: configur3+ations.jacocoAnt.asPath` * **Fix:** It should be `configurations.jacocoAnt.asPath`. <!-- end list --> ```groovy // In your JaCoCo task ant.taskdef(name: 'report', classname: 'org.jacoco.ant.ReportTask', classpath: configurations.jacocoAnt.asPath) // FIX: Was 'configur3+ations' ``` ----- ### \#\# 2. Major Structural Problems Your project's build logic is incorrectly structured. You've mixed settings for the root project and the `model_base` module into one file. #### **A. Root Project and Module Logic are Mixed** You should have at least two `build.gradle` files: one in the project's root directory and one inside your `model_base` module. * **Project Root `build.gradle` or `build.gradle.kts`:** Should contain `buildscript` settings (like the Android Gradle Plugin version) and `allprojects` repository settings. It should **not** contain `apply plugin: 'com.android.library'` or Android-specific settings like `compileSdk`. * **Module `app/build.gradle` or `library/build.gradle.kts`:** Should contain `plugins { id 'com.android.library' }`, the `android { ... }` block, and the `dependencies { ... }` for that specific module. #### **B. Action Plan: Restructure Your Files** **Step 1: Create a `settings.gradle` file in your project root** (if you don't have one). It tells Gradle which modules are part of your project. ```groovy // settings.gradle include ':model_base' // include ':app' // if you have an app module ``` **Step 2: Clean up your Root `build.gradle` file.** It should only contain build-wide information. ```groovy // Project Root: build.gradle // The buildscript block is an older pattern, but if you keep it: buildscript { repositories { google() mavenCentral() } dependencies { // Use a consistent version for AGP classpath 'com.android.tools.build:gradle:8.1.0' // You don't need JaCoCo here; the plugin handles it. } } allprojects { repositories { google() mavenCentral() maven { url "https://jitpack.io" } } } ``` **Step 3: Create/Fix your Module `model_base/build.gradle` file.** This is where most of your current code should go. ```groovy // Module: model_base/build.gradle // Use the plugins block at the top plugins { id 'com.android.library' id 'jacoco' // Apply jacoco plugin here } android { namespace 'com.st.model_base' compileSdk 34 defaultConfig { minSdk 29 targetSdk 34 // Corrected typo } // ... your other android settings } dependencies { // ... your dependencies implementation 'androidx.appcompat:appcompat:1.6.1' // Updated version } // ... your JaCoCo tasks and configuration ``` ----- ### \#\# 3. Bad Practices and Recommendations These are issues that make your build slow, fragile, and hard to maintain. #### **A. Manual `bootstrapClasspath` Manipulation is Very Bad** Your use of `options.compilerArgs << '-Xbootclasspath/p:...'` and manually rebuilding the `bootstrapClasspath` to include `framework.jar` is an extremely fragile and outdated practice. * **Why it's bad:** It overrides the standard Android compile environment. It can break with any update to AGP, Gradle, or Java. It makes your build completely dependent on a local JAR file. * **Recommendation:** **Remove all three `gradle.projectsEvaluated` blocks.** Rely on the `compileSdk 34` to provide the Android APIs. If you absolutely need APIs not available in the public SDK, this approach is still not recommended and indicates a potential design flaw. #### **B. `dependsOn(clean)` is an Anti-Pattern** Your line `createOfflineTestCoverageReport.dependsOn(clean)` is very inefficient. * **Why it's bad:** It forces a complete project clean and recompile **every time** you want to generate a report. This will make your build process incredibly slow. * **Recommendation:** **Delete this line.** Gradle's tasks are designed to be incremental. #### **C. Redundant Configurations** You have multiple `tasks.withType(Test)` and `gradle.projectsEvaluated` blocks. This makes the script confusing. * **Recommendation:** Combine them into single blocks to avoid conflicts and make the logic clear. #### **D. Outdated Dependencies and Repositories** * **JCenter is Deprecated:** Remove `jcenter()` from your repositories. It was shut down years ago and can slow down your build as Gradle tries to connect to it. `mavenCentral()` has replaced it. * **Old AppCompat Library:** `androidx.appcompat:appcompat:1.4.1` is old for `compileSdk 34`. Update it to a more recent version like `1.6.1` to avoid potential incompatibilities.
最新发布
07-24
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值