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. 开发环境搭建可以 ...
随机推荐
- CF369E Valera and Queries kdtree
给你一堆线段,求:一个区间内包含的本质不同线段种类数(只要线段有一部分在区间中就算是包含) 考虑容斥:总线段数-被那些没有询问的区间完全覆盖的数量. 用离线+树状数组数点或者 KDtree 数点即可. ...
- luogu 4211
题意 存在一棵树,每次询问 \(l, r, z\) 求 \[\sum_{i = l} ^ {r} deep(lca(i, z))\] 考虑 lca 的实质:两点到根的路径的交集中深度最大的点 其中一点 ...
- angular2事件触发
输入框输入过程触发Select()方法. <input type="text" name="code" [(ngModel)]="code&qu ...
- Luogu2791 幼儿园篮球题【斯特林数,数学】
题目链接:洛谷 我一开始不知道$N,M$有什么用处,懵逼了一会儿,结果才发现是输入数据范围... $$\begin{aligned}\binom{n}{k}Ans&=\sum_{i=0}^k\ ...
- vue中封装一个倒计时
<template> <div class="countDownBox"> <div class="row resetStyle" ...
- 带着历史提交记录迁移git仓库
1. git push --mirror --mirror模式会把本地的分支都克隆 // 先用--bare克隆裸仓库 git clone git@gitee.com:zhangamie/testApp ...
- 理解 java 使用 异或 交换两数
网上看了一些使用异或交换两数,不是很好理解.现在写一下自己的理解. 首先是 异或原则,对于任意 x: x ^ x == 0; x ^ 0 == x; 思路: 根据原则,可以得到两个公式: 求a: ...
- python pillow 处理图片
demo1 #打开图片,并随机添加一些椒盐噪声 from PIL import Image import numpy as np import matplotlib.pyplot as plt img ...
- python3编程基础之一:关键字
在学习编程的过程中每种语言都会有一些特殊的字母组合在本语言中表示特定的含义,这种字母组合就是关键字.原则上,关键字是无法被重复定义的,否则,语言在应用中,就无法正确确定标号的意义了. 1.关键字的获取 ...
- 在 Arch 上Yaourt 使用这些替代品
1. aurman aurman 是最好的 AUR 助手之一,也能胜任 Yaourt 替代品的地位.它有非常类似于 pacman 的语法,可以支持所有的 pacman 操作.你可以搜索 AUR.解决包 ...