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. 开发环境搭建可以 ...
随机推荐
- KindEditor3.x-自动上传Word图片功能.
Chrome+IE默认支持粘贴剪切板中的图片,但是我要发布的文章存在word里面,图片多达数十张,我总不能一张一张复制吧?Chrome高版本提供了可以将单张图片转换在BASE64字符串的功能.但是无法 ...
- jQuery相关方法1
一.设置某个元素的标签内容------.html()方法 <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js& ...
- JavaScript--自定义事件Event
在开发过程中,js原生事件不足以满意开发需求,需要开发者自定义事件. 一.Event Event()构造函数创建一个新的Event. event = new Event(typeArg,eventIn ...
- slax自启动程序
Fluxbox 本身提供了自启动程序的功能.~/.fluxbox/startup 文件是一个像启动 Fluxbox 一样自启动应用程序的脚本.# 标记是注释. 一个简单的例子: #!/bin/sh # ...
- MyBatis:Error evaluating expression ''''. Return value () was not iterable错误
Error evaluating expression ''''. Return value () was not iterable 出现原因:xml文件中遍历List 时,该参数的实际值为非Lis ...
- Windows下OpenFOAM开发及使用环境配置指南 (2)【转载】
转载自:http://openfoam.blog.sohu.com/158751915.html *************************************************** ...
- Apache Flink - Component Stack
作为一个软件堆栈,Flink是一个分层的系统.堆栈的不同层构建在彼此之上,并提高程序表示的抽象级别: 在runtime层以JobGraph的形式接受一个程序.JobGraph是一个通用的并行数据流,包 ...
- IdentityServer4入门五:错误处理
在访问ClientMvc的保护页面时,会跳转到IdentityMvc页面,这时会出现类似下图的错误界面,让人无从入手. 如果你尝试按文字所说的内容去处理.你发现项目已正确设置.其实上面的内容是固定的, ...
- php手记(替代语法、COOKIE及时生效)
为方便区分流程语句的开始和结束位置,可以使用PHP提供的替代语法进行编码. 左花括号({) - 替换成 → 冒号(:) 右花括号(}) - 替换成 → "endif;" " ...
- Go 语言入门(三)并发
写在前面 在学习 Go 语言之前,我自己是有一定的 Java 和 C++ 基础的,这篇文章主要是基于A tour of Go编写的,主要是希望记录一下自己的学习历程,加深自己的理解 Go 语言入门(三 ...