-
在mysql高版本上配置数据库时,url不能简单的按照视屏中写,需要按照下面的: url: jdbc:mysql://127.0.0.1:3306/sbs?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC 否则会出现下面的异常: SQLException: The server time zone value '�й���ʱ��' is unrecognized查看全部
-
数据仓库:
1.数据仓库类只需要继承JpaRepository<Girl,Integer>即可
--------------------------------------------------------------------------------
public interface GirlRepository extends JpaRepository<Girl,Integer>{
}
--------------------------------------------------------------------------------
2.数据仓库类(GirlRepository )常用api
@Autowired
private GirlRepository girlRepository ;
girlRepository .findAll();返回List<Girl>集合
girlRepository .save(); 返回Girl对象
girlRepository .findOne(); 返回Girl对象
girlRepository .findByAge(); 返回List<Girl>集合,会生产与属性相关的方法
查看全部 -
@RestController相当于@ResponseBody与@Controller
@RequestMapping(value={"/hi","/say"}),value可以是个集合
@RequestMapping可以用GetMapping或@postMapping代替,省去声明方法
@getMapping(value="/{id}/say")
xxx(@pathVariable("id") Integer id)
此种方法也可以取到值
查看全部 -
一 配置文件:
1. @value("${abc}")直接取值
2.配置文件可以取配置文件中的值
content: “abc: ${adc}”
3.@value
@Component 与@ConfigurationProperties组合使用创建配置类bean
二 带上配置环境启动方式:
jar -jar girl-0.0.1-snapshot.jar --spring.profiles.active=dev
查看全部 -
@Controller 处理http请求
@RestController Spring4之后新加的注解,原来返回json需要@ResponseBody配合@Controller
@RequestMapping(value = {"/hello", "/hi"}, method = RequestMethod.GET) 两个url路径都可以访问同一个方法
当不指定请求方式时,get/post都可以请求到,但是不推荐。
该注解可以给整个类指定Url
处理url里面的参数:
@PathVariable 获取url中的数据
@RequestParam 获取请求参数的值
@GetMapping/PostMapping 组合注解(感觉@RequestMapping 参数太长,可以用这些替换)
查看全部 -
这位同学我感觉你在误导大家,我多番尝试验证,配置映射类的名字跟项目名完全无关,可能是你自己的配置问题。 很简单:假如类型都被指定了,那配置中其他前缀的配置该用什么名字做实体类。希望你考证后再发出来,免得误导别人!!!!!!!!!
@采集数最多的那个同学
查看全部 -
启动springboot的3种方式
1、正常idea启动
2、mvn spring-boot:run
3.mvn install
java -jar xx.jar
查看全部 -
spring: profiles: active: prod 指定读取的配置文件,注意,每一个:后面需要跟一个空格,yml文件格式 自定义对象girl,需要在实体类名上加@ConfigurationProperties(prefix="girl"),还需要加上@Component.否则找不到实体类的bean查看全部
-
1. 3个注解的使用: a. @Value 从配置文件读取参数 b. @ConfigurationProperties 把yml里面一组配置参数封装成一个类 c. @Component 向SpringBoot注册一个类 d. @Autowired 注入一个类 2.yml配置文件的使用 3.多配置文件的使用 application-dev.yml 开发环境配置文件 application-prod.yml 生产环境配置文件 application.yml 环境切换配置文件 spring: profile: active:dev 切换到开发环境,如果是prod切换到生产环境 或者是把工程编译打包之后,在命令行运行 以生产模式运行 java -jar GirlApplication-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod 以开发模式运行: java -jar GirlApplication-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev查看全部
-
post的,我按照老师的办法会报如下错误 { "timestamp": 1506939541553, "status": 400, "error": "Bad Request", "exception": "org.springframework.web.bind.MissingServletRequestParameterException", "message": "Required String parameter 'cupSize' is not present", "path": "/girls" } 我自己试了下,填写到Params里面的key-value键值对里面就没有问题,请大家知道这种情况查看全部
-
@RestController==@Controller +@ResponseBody 匹配多个路径: @RequestMapping(value={“hello”,“hi”} ,method=RequestMethod.GET) Controller获取参数: 1:@RequestMapping(value = "/hello/{id}",method = RequestMethod.GET) @PathVariable("id") Integer myId,获取url中的数据http:xx/hello/99 2: @RequestParam,获取请求参数的值http:project/hh/name=XX @RequestParam(value="id",required = false(是否为必传),defaultValue = "0") 3:@GetMapping,组合注解 @GetMapping() 就是 @RequestMapping(value= ,method=RequestMethod.GET) @PostMapping()查看全部
-
ddl-auto: create 每次都会创建表 如果表存在就会先drop再create ddl-auto: update 表不存在就create 表存在就update ddl-auto: validate 验证表结构 ddl-auto: create-drop 程序结束后会把表drop掉查看全部
-
ddl-auto: create 每次都会创建表 如果表存在就会先drop再create ddl-auto: update 表不存在就create 表存在就update ddl-auto: validate 验证表结构 ddl-auto: create-drop 程序结束后会把表drop掉查看全部
-
<mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyuan</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> 阿里云的镜像配置文件,应该放在POM文件哪个位置?查看全部
-
SpringBoot返回JSON数据不需配置,直接在方法上添加@ResponseBody即可. @GetMapping()、@PutMapping()、@PostMapping()、@DeleteMapping()、@RequestMapping. @GetMapping() 只接收GET请求. @PutMapping() 只接收Put请求 @PostMapping() 只接收Post请求. @DeleteMapping() 只接收Delete请求. @RequestMapping() 默认都可以接收,可通过method属性设置. 都有value属性设置映射的url,可以是多个url. @RequestMapping({"",""})查看全部
举报