eclipse-springboot遇到的问题。

本文涵盖SpringBoot项目中常见的安装、配置、依赖管理和运行时问题,包括插件下载、Maven依赖错误、端口冲突、页面访问失败、MyBatis参数绑定异常及调试技巧,提供实用的解决步骤。

1)在这里下载对应版本的插件https://spring.io/tools3/sts/all

注意后缀一定要是updatesite的

否则会出现No software site found at jar的错误

2)安装时出现
An error occurred while collecting items to be installed session context was:(profile=SDKProfile, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
No repository found containing: osgi.bundle,org.codehaus.jackson.core,1.9.13
No repository found containing: osgi.bundle,org.codehaus.jackson.mapper,1.9.13
错误

repository仓库
解决方法:先看一下自己的Eclipse->Window->Preference->Install/Update下
在这里插入图片描述 根据红色框标识改为Disable

(3)pom.xml文件第一二行出错
Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.18.1 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.18.1 from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled.

原理:Maven包出错,在.m库中找到对应的包,删除。
再用update更新一下。
cached 藏起
assign分配归属

(4)启动后:Address already in use: bind
把8080强制关闭。

(5)springboot启动项目后不能访问templates下的页面
1)update一下
2)我的配置文件里是对jsp的支持,不是对thymeleaf的支持。

6)server.context-path= # Context path of the application. 应用的上下文路径,也可以称为项目路径,是构成url地址的一部分。
默认可以不配置,直接在controller层通过@RequestMapping来设定url的地址路径。

@controller和@restcontroller的区别

7)Resolved exception caused by Handler execution: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter ‘password’ not found. Available parameters are [0, 1, param1, param2]

参数没有找到。
传入多个值时,mybatis会自动将这些值转成类似map形式的值,以0,1,2…的序列为keyName。

@Select(“select * from fruitsell where f_id=#{f_id} and u_id=#{u_id}”)
public Fruitsell finbyfruitsell(@Param(“f_id”) Long f_id,@Param(“f_id”) Long u_id);

加一个@Param注解就可以了

8)springboot单点调试
修改pom.xml

	<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<fork>false</fork>
	                <jvmArguments>
	                	-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
	                </jvmArguments>
            	</configuration>
			</plugin>

添加一个false,就搞定了。

### 如何运行基于 Vue 和 Spring Boot 的图书馆管理系统项目 运行一个基于 Vue 和 Spring Boot 的图书馆管理系统项目需要分别对前端(Vue)和后端(Spring Boot)进行配置和启动。以下是详细的说明: #### 1. 环境准备 确保开发环境已安装以下工具: - Java Development Kit (JDK) 版本 8 或更高版本[^2]。 - Maven 或 Gradle 构建工具,用于构建和管理 Spring Boot 后端项目[^3]。 - Node.js 和 npm/yarn,用于构建和运行 Vue 前端项目[^4]。 #### 2. 后端(Spring Boot)的运行 Spring Boot 是一个轻量级框架,其继承了 Spring 框架的优秀特性,并通过简化配置文件来进一步简化了应用的搭建和开发过程[^1]。以下是运行 Spring Boot 后端的具体步骤: - **导入项目**:将项目导入到 IDE(如 IntelliJ IDEA 或 Eclipse),并确保 Maven/Gradle 依赖项已正确下载。 - **配置数据库**:根据项目的 `application.properties` 或 `application.yml` 文件,配置数据库连接信息(如 MySQL、PostgreSQL 等)[^5]。 - **运行项目**:右键点击主类(通常命名为 `Application.java` 或类似名称),选择“Run”以启动 Spring Boot 应用程序。默认情况下,Spring Boot 应用会在 `http://localhost:8080` 上运行[^6]。 #### 3. 前端(Vue)的运行 Vue 是一个渐进式 JavaScript 框架,适合构建单页应用程序(SPA)。以下是运行 Vue 前端的具体步骤: - **安装依赖**:进入 Vue 项目的根目录,执行以下命令以安装项目所需的依赖项: ```bash npm install ``` 或者使用 Yarn: ```bash yarn install ``` - **运行开发服务器**:安装完成后,启动 Vue 开发服务器: ```bash npm run serve ``` 或者: ```bash yarn serve ``` 默认情况下,Vue 应用会在 `http://localhost:8081` 或其他指定端口上运行[^7]。 #### 4. 配置前后端交互 为了确保 Vue 前端能够与 Spring Boot 后端正常通信,需完成以下配置: - 在 Vue 项目中,设置 API 请求的基础 URL 为后端服务地址(如 `http://localhost:8080`)[^8]。 - 如果遇到跨域问题,可以在 Spring Boot 中添加 CORS 支持。例如,在主类或配置类中添加以下代码: ```java @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedOrigins("http://localhost:8081"); } }; } ``` #### 5. 测试系统功能 在前后端均成功运行后,可以通过浏览器访问 Vue 前端页面,并测试图书馆管理系统的各项功能是否正常工作。 ```python # 示例代码:简单的 Spring Boot 控制器 @RestController @RequestMapping("/books") public class BookController { @GetMapping public List<Book> getAllBooks() { // 返回图书列表 return bookService.getAllBooks(); } } ``` ### 注意事项 - 确保前后端的接口定义一致,避免因数据格式不匹配导致的问题[^9]。 - 如果项目中有额外的依赖或插件,请参考项目文档或 `README.md` 文件进行配置[^10]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值