贵阳网站建设蜜蜂,东莞建站方案,做漫画网站的需求,一个网络空间如何做两个网站方式1:在线创建项目
https://start.spring.io/ 环境准备
#xff08;1#xff09;JDK 环境必须是 1.8 及以上#xff0c;传送门#xff1a;jdk1.8.191 下载#xff08;2#xff09;后面要使用到 Maven 管理工具 3.2.5 及以上版本#xff08;3#xff09;开发工具建议…
方式1:在线创建项目
https://start.spring.io/ 环境准备
1JDK 环境必须是 1.8 及以上传送门jdk1.8.191 下载2后面要使用到 Maven 管理工具 3.2.5 及以上版本3开发工具建议使用 IDEA 方式2IDEA创建
1.IDEA创建 创建之后等待编译完成 过程时间很多。可能10多分钟也可能几个小时
启动 启动时报错
出现的错误No MyBatis mapper was found
解决1启动类头加上忽略mapper配置 报这种错的原因在于spring boot默认会加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration类而DataSourceAutoConfiguration类使用了Configuration注解向spring注入了dataSource bean。因为工程中没有关于dataSource相关的配置信息当spring创建dataSource bean因缺少相关的信息就会报错。 如果我们用SpringBoot实现一个简单的微服务不需要数据库我们可以这样解决在application类加上注解(exclude{})
//禁用数据库自动配置,
SpringBootApplication(exclude {DataSourceAutoConfiguration.class,DataSourceTransactionManagerAutoConfiguration.class,HibernateJpaAutoConfiguration.class})
public class Demo17Application {public static void main(String[] args) {SpringApplication.run(Demo17Application.class, args);}}解决2启动类头加上mapper配置 配置服务器端口
application.properties #配置端口 server.port8088 新建Controller
新建一个Controller目录创建了一个类 package com.example.demo17.controller;import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;Controller
RequestMapping(/hello)
public class HelloWorld {RequestMapping(/hellowold)public String helloworld() {return Hello Lain;}
}调用一个Controller
创建好HelloWorld控制器之后在浏览器http://localhost:8088/hello/hellowold SpringBoot 项目创建与运行成功~~~~