eclipse搭建springboot的项目
记录一次自己搭建springboot的经历
- springboot项目创建
这里借用别的博主分享的方法 https://blog.csdn.net/mousede/article/details/81285693
- 目录结构

- 接下来是编写一个启动类
启动类:SpringBootDemoApplication
package com.start; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication(scanBasePackages = "com")
@MapperScan({"com.start.mangage.repository","com.start.mangage.service"})
public class SpringBootDemoApplication { public static void main(String[] args) {
SpringApplication.run(SpringBootDemoApplication.class,args);
}
}
新建一个配置文件起名application.properties
#服务器端口号
server.port=8011
这里我使用maven建的项目 所以依赖就需要在pom.xml中加入下面一些依赖 原本的你不用管放里面就可以了
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>1.2</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<build>
<plugins>
<!-- 资源文件拷贝插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
到这里基本一个项目就搭建好啦,用浏览器访问http://localhost:8011就可以访问默认首页
下面是我第一次搭建过程中最为头疼的地方了 百度了很多才解决
- 如何访问静态资源
首先需要在目录中创建文件夹static(存放js,css等)和templates(存放页面文件jsp,html等)

在pomxml中添加依赖
<!-- 访问静态资源 -->
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency -->
<!-- jsp依赖 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jsp-api</artifactId>
</dependency> <resources>
<resource>
<directory>src/main/java</directory>java文件的路径
<includes>
<include>**/*.properties</include>
<include>**/*.*</include>
</includes>
<!-- <filtering>false</filtering> -->
</resource>
<resource>
<directory>src/main/resources</directory>资源文件的路径
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
这里一开始我用 thymeleaf 这里依赖导致我怎么也访问不到我的jsp格式的页面,后来我改用了jsp依赖就可以,就是一个依赖的问题把我这初学者难上了天,唉!
配置文件中添加
#配置jsp视图的位置和后缀
spring.mvc.static-path-pattern=/**
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
然后我建了一个controller类,测试了一下访问页面,成功访问到了。
勤能补拙,努力努力!
eclipse搭建springboot的项目的更多相关文章
- Eclipse 搭建 Maven Web项目
第一步:安装JDK: 第二步:安装Eclipse: 第三步:安装tomcat7: 第四步:安装maven插件: 4.1 下载maven:http://maven.apache.org/download ...
- (A)eclipse搭建springboot项目入门
网上许多资料都是用idea的,但是我个人用eclipse习惯了,所以就在eclipse里面自己尝试着写了一个hello. 然而项目建好后却迟迟不能访问!!!网上搜了许多资料都不靠谱! 虽然最后能看到h ...
- 手把手教你从零开始搭建SpringBoot后端项目框架
原料 新鲜的IntelliJ IDEA.一双手.以及电脑一台. 搭建框架 新建项目 打开IDE,点击File -> New Project.在左侧的列表中的选择Maven项目,点击Next. 填 ...
- 使用eclipse搭建springboot项目pom.xml文件第一行报错(Maven Configuration Problem)
今天在https://start.spring.io/上搭建了一个2.1.5版本的springboot项目,但是把它导入后,pom.xml第一行报错了,查看Problems发现下面的错误 百度后发现方 ...
- eclipse 搭建springboot项目pom.xml报错
1. 报错信息 2. 解决方法 在pom.xml文件中加入maven版本修改 <maven-jar-plugin.version>3.1.1</maven-jar-plugin.ve ...
- Eclipse搭建SpringBoot之HelloWorld
你的eclipse需要先安装 Spring Tool Suite™ 第一种方法(不建议,之所以贴上是因为探索的过程) 首先新建Maven工程 勾选第一个按钮,第三个是选择working set ,你可 ...
- Eclipse搭建SpringBoot
第一种方法(不建议) 首先新建Maven工程 勾选第一个按钮,第三个是选择working set ,你可以不选 下一步,配置工程信息,注意打包为jar 打开pom.xml文件,添加spring-boo ...
- Eclipse 搭建tomcat+动态项目完整版
1. Tomcat搭建 1.新加服务器,右击控制台的server目录->new->server->选择本地tomcat 2.配置tomcat属性(如果更改失败,将tomcat下的项目 ...
- Eclipse搭建maven web项目
最近在做做一个小实验,搭建ssm框架,要求使用maven来统一管理jar包,接下来就看如何建立maven项目,首先必须有要有相应的开发环境:JDK和maven,以及配置tomcat. 开发环境搭建可以 ...
随机推荐
- php des 对称加解密类
<?php header("Content-Type: text/html;charset=utf-8"); /** * des 对称加解密 */ class des { p ...
- ckeditor自定义工具栏
/** * 获取编辑器工具栏自定义参数 * @param type 类型 simple=极简版 basic=基本版 full=完整版 */ function get_ckeditor_toolbar( ...
- spring cloud 常见面试题 来理解微服
为什么要谈 这些理论知识呢 理论知识 = 面试时候的谈资 !!! 你只有 进去公司 才有资格 去做一个码农 ok 话不多说 经历如此漫长的互联网发展 以本人的拙见 软件开发 粗略的 分为 ...
- bind--dns-docker---[nslookup/dig]
[dig] https://www.cnblogs.com/apexchu/p/6790241.html [dns resolution and revserse ]https://www.cnbl ...
- docker安装hbase
.下载安装Hbase: ().docker search hbase : 查找Hbase ().docker pull harisekhon/hbase:1.3 注意:不要安装最新版本的,不稳定 (我 ...
- Echarts 常用API之action行为
一.Echarts中的action echarts中支持的图表行为,通过dispatchAction触发. 1.highlight 高亮指定的数据图形 dispatchAction({ type: ' ...
- 使用INDY解决BASE64回车换行问题
使用INDY解决BASE64回车换行问题 使用DELPHI EncodeStream(),对流数据进行BASE64编译以后,每隔75个字符,就会添加回车换行符(#$D#$A),这会造成许多问题. 网上 ...
- java spark list 转为 RDD 转为 dataset 写入表中
package com.example.demo; import java.util.ArrayList; import java.util.Arrays; import java.util.Hash ...
- 面试准备4——C++相关知识
指针和引用区别: (1)指针: 指针是一个变量,只不过这个变量存储的是一个地址,指向内存的一个存储单元: 引用跟原来的变量实质上是同一个东西,只不过是原变量的一个别名而已. 如: int a=1;in ...
- angular自定义组件
https://cli.angular.io/ 打开终端创建header组件: ng g component components/header import { Component, OnInit ...