基于spring boot 的ssm项目的简单配置

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

我前面的帖子有介绍spring boot的简单搭建,现在我再讲讲spring boot的简单配置

首先,项目结构

823677edee3f5dec7168b700d22d319a9cb.jpg

启动类

@RestController    注解相当于@ResponseBody + @Controller合在一起的作用。
@SpringBootApplication     项目创建默认的注解,解释的话有点多直接贴网址大家自己进去了解   https://blog.csdn.net/dyangel2013/article/details/79775122    
@EnableAutoConfiguration     详细的自己去了解一下   https://blog.csdn.net/zxc123e/article/details/80222967

package com.example;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@SpringBootApplication
@EnableAutoConfiguration
public class BaiduditudemoApplication {public static void main(String[] args) {SpringApplication.run(BaiduditudemoApplication.class, args);}
}

pojo包下不需要什么注解

我倒是了解到现在可以加入

@Getter
@Setter
@ToString

可以让你省略掉冗余的get  set 方法和toString方法

 

mapper包下是接口和mapper文件

6ca5e35125b1ca572daa072a78c17f7f239.jpg

接口依然不需要什么注解,mapper文件中需要注意的有一点

1中是对应的接口位置

2中对应pojo实体类

0ab058dc024e03c7439353de87990b67b3f.jpg

service包下的结构

f7f8b671ffe0e72b7f04fa9ec0805064fed.jpg

接口依然没有什么注解,service的实现类需要加入@service注解

也可以加上@Transactional事务处理的注解,事务处理在启动类也可以用另一个注解加入

 

这是application.properties里的配置

spring.datasource.url=jdbc:mysql://localhost:3306/mpms
spring.datasource.username=root
spring.datasource.password=123
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database=mysql

最后就是pom文件了,当然pom文件肯定不是最后才配置的,我只是放在最后说

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.3.RELEASE</version><relativePath /> <!-- lookup parent from repository --></parent><groupId>com.example</groupId><artifactId>baiduditudemo</artifactId><version>0.0.1-SNAPSHOT</version><name>baiduditudemo</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-aop</artifactId></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>1.1.1</version></dependency><!-- http --><!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore --><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpcore</artifactId><version>4.4.10</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpclient</artifactId><version>4.5.6</version></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

很多注解我也不是很深入的理解,目前只能说是能够运用,大家多多谅解不能详细给大家解释

转载于:https://my.oschina.net/u/4100388/blog/3028785

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/279817.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

nest 架构_如何与其他人分享您的Nest Cam Feed

nest 架构Your Nest Cam can help you keep an eye on your home from anywhere you are, but more eyes you trust to watch your stuff is more comforting. If you want someone else to check in once in a while, you can share your Nest Cam feed with a simple, passwo…

关于公司内部DNS的整改建议

文章背景&#xff1a;由给leader的邮件而来&#xff0c;在文章末尾另加了一些补充&#xff08;见FAQ&#xff09;。原主题&#xff1a;关于公司内网DNS服务器中的u-sooc.com域名调整建议 建议&#xff1a;将公司内部DNS服务器&#xff08;Windows Server 2008 R2&#xff09;所…

.Net 和Assembly下滑其它回升,TIOBE编程语言2022年12排行榜

楔子TIOBE编程语言排行榜一般反应的是语言的生态&#xff0c;个人比较喜欢这个排行。来看下2022年最后一个月12月&#xff0c;最后一天,TIOBE的排行榜单。榜单分析这里只看下前10名的编程语言&#xff0c;里面非常显眼的是所有的语言都增加了生态环境&#xff0c;包括不被看好的…

Haproxy安装与配置

Haproxy安装与配置 有关高负载均衡的软件&#xff0c;目前使用比较多的是haproxy、nginx和lvs。下面我们就开始学习haprxoy这款软件。 1、Haproxy概念 1.1、haproxy原理 haproxy提供高可用性、负载均衡以及基于TCP(第四层)和HTTP&#xff08;第七层&#xff09;应用的代理&…

删除word中所有的表格_如何在Word中删除表格

删除word中所有的表格If you’ve inserted a table in Word and you now want to delete it, you may have found it’s not all that straightforward to delete the entire table without deleting other content around the table. We’ll show you a couple of ways around…

Java web application——基础

概述 一个WAR文件包含了构成一个Web应用程序所需要的文件。WAR文件作为一个单元部署在一个或多个WebLogic Server实例上。 WebLogic Server上的Web存档始终包含以下文件&#xff1a; 一个servlet或Java Server Page&#xff08;JSP&#xff09;&#xff0c;以及任何帮助程序类。…

Jenkins在windows平台下,让Powershell和批处理可以拉起进程并保持

&#x1f4e2;欢迎点赞 &#xff1a;&#x1f44d; 收藏 ⭐留言 &#x1f4dd; 如有错误敬请指正&#xff0c;赐人玫瑰&#xff0c;手留余香&#xff01;&#x1f4e2;本文作者&#xff1a;由webmote 原创&#x1f4e2;作者格言&#xff1a;无尽的折腾后&#xff0c;终于又回到…

ASP.NET高并发解决方案

一、页面静态化&#xff1b; 二、运用WCF,WEB SERVICE等技术实现分布式业务逻辑处理及数据访问的能力&#xff1b; 三、页面缓存&#xff1b; 四、数据缓存&#xff1b; 五、建立图片文件服务器&#xff1b; 本文转自 梦在旅途 博客园博客&#xff0c;原文链接&#xff1a;http…

MVC身份验证及权限管理(转载)

from https://www.cnblogs.com/asks/p/4372783.html MVC自带的ActionFilter 在Asp.Net WebForm的中要做到身份认证微软为我们提供了三种方式&#xff0c;其中最常用的就是我们的Form认证&#xff0c;需要配置相应的信息。例如下面的配置信息&#xff1a; <authentication mo…

面试问题总结

面试了两家公司&#xff0c;第一家没有笔试直接面试&#xff0c;第二家笔试面试&#xff0c;将记得住的问题记录下来&#xff0c;答案自己找的&#xff0c;有好的答案欢迎提出。 1、响应式布局 一家公司问了em和rem的区别&#xff0c;另一家公司先问了一下px,em,rem的区别&…

WPF-23 基于Timer任务调度

.NET的FCL中提供了几个计时器&#xff0c;大多数初学者都不清楚他们有什么不同&#xff0c;那我们这节来剖解一下每个计时器的本质&#xff1a;1.System.Threading.Timer如果在一个线程池上执行一个定时的周期性的后台线程任务他是最好的选择&#xff0c;这个类是和线程池相关联…

在.NET中不安装Office使用EPPlus生成带图表(Chart)的Excel报表

在开发.NET应用中可能会遇到需要生成带图表(Chart)的Excel报表的需求&#xff0c;特别是在一些ASP.NET网站中&#xff0c;有时候我们并不能保证Web服务器上一定安装了Office组件&#xff0c;所以使用微软的Office来生成Excel并不保证在所有情况下都使用&#xff0c;有时候即使W…

facebook 邀请好友_如何在Facebook上与某人解除好友

facebook 邀请好友It’s very easy for your Facebook News Feed to get cluttered. After a few years adding ukulele playing magicians you meet wandering the street and the bar staff at every bar you go to regularly, it gets overrun with people you’ll never se…

mac下npm/node的安装和卸载、升级;node、npm升级后最后删掉node_modules重新安装

mac还是使用brew install简单一些&#xff1b;最好使用一种安装方式&#xff0c;不要多种方式互用&#xff1b; 更新npm到最新版本npm install -g npm更新npm到指定版本 npm -g install npm2.9.1指定安装目录npm install --prefix /usr/local -g npm 1、从官网https://nodejs.o…

软件工程小组第三次正式会议

会议主题&#xff1a;主要确定数据库具体内容与会时间&#xff1a;3月29日与会地点&#xff1a;图书馆小组研究室雨水612与会成员&#xff1a;尚卓燃、张世豪、王昊钰、傅宇豪会议记录&#xff1a; 小组成员一起讨论数据库&#xff0c;确定了数据库中的实体、属性、联系&#…

Edison的2022年终总结

大家好&#xff0c;我是Edison。2022年即将结束&#xff0c;又到了做年终总结的时候&#xff0c;它是我每年的一个习惯&#xff0c;意味着又要开始新的征途&#xff0c;在开始新的征途之前回顾一下很有必要。艰难抉择&#xff1a;从互联网到制造业今年最大的变化就是又换了份工…

JNI

配置NDK&#xff0c;调用JNI最终会生成一个so库&#xff0c;如果so库生成了。直接在项目中使用so库即可调用本地方法。注意&#xff1a;api的包名要与so库定义的包名一致。 1什么是jni jni java native interface java本地开发接口&#xff0c;是JAVA和C互相调用的桥梁。 2jni有…

dvd vlc 复制_如何使用VLC翻录DVD

dvd vlc 复制There are many ways to rip a DVD to your computer, but if you’re looking for the most straightforward option, VLC is easy and free. Besides, you probably already have VLC on your computer (and if you don’t, you should). Here, we’ll show you …

新年芯事 | 龙芯物联网主控芯片龙芯1C102和龙芯1C103流片成功

前言近期&#xff0c;龙芯中科面向物联网领域研制的主控芯片--龙芯1C102和龙芯1C103流片成功&#xff0c;两款微控制器芯片各项功能测试正常&#xff0c;符合设计预期。 龙芯1C102主要面向智能家居以及其他物联网设备详细介绍龙芯1C102采用龙芯LA132处理器核心&#xff0c;是一…

Javascript基础学习20问(二)

1.函数&#xff08;方法&#xff09;&#xff1a;封装执行一项专门任务的步骤的代码序列--》重用2.参数&#xff1a;方法内独有的变量&#xff0c;接受传入数据&#xff0c;在方法中处理3.作用域&#xff1a;一个变量的可用范围 全局作用域&#xff1a;全局变量 局部作用…