spring cloud 为开发人员提供了快速构建分布式系统的一些工具,包括配置管理、服务发现、断路器、路由、微代理、事件总线、全局锁、决策竞选、分布式会话等等。它运行环境简单,可以在开发人员的电脑上跑。另外说明spring cloud是基于springboot的,所以需要开发中对springboot有一定的了解,另外对于“微服务架构” 不了解的话,可以通过搜索引擎搜索“微服务架构”了解下。
#db
spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
mybatis.mapper-locations=classpath*:/mybatis-mapping/*Mapper.xml
# Specify the DBMS
spring.jpa.database = MYSQL
# Show or not log for each sql query
spring.jpa.show-sql = true
3:在原来的启动类:EurekaProvideApp.java上面加入注解
package spring.cloud.ykf.eureka.provide.main;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
//标明是服务提供者
@EnableEurekaClient
// springboot项目
@SpringBootApplication
@MapperScan("spring.cloud.ykf.eureka.provide.main.mapper")
public class EurekaProvideApp {
public static void main(String[] args) {
System.err.println("EurekaProvideApp Service Strat Success!");
SpringApplication.run(EurekaProvideApp.class, args);
}
}
4:新建一个Userservice
package spring.cloud.ykf.eureka.provide.main.service;
import spring.cloud.ykf.eureka.provide.main.entry.User;
public interface UserService {
User findUser(Integer id);
int saveUser(User user);
int deleteUser(Integer id);
}
5:实现类
package spring.cloud.ykf.eureka.provide.main.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import spring.cloud.ykf.eureka.provide.main.entry.User;
import spring.cloud.ykf.eureka.provide.main.mapper.UserMapper;
import spring.cloud.ykf.eureka.provide.main.service.UserService;
@Service
public class UserServiceImpl implements UserService {
@Autowired
UserMapper userMapper;
@Override
public User findUser(Integer id) {
return this.userMapper.findUser(id);
}
@Override
public int saveUser(User user) {
this.userMapper.saveUser(user);
return 1;
}
@Override
public int deleteUser(Integer id) {
this.userMapper.deleteUser(id);
return 1;
}
}
6:UserMapper
package spring.cloud.ykf.eureka.provide.main.mapper;
import spring.cloud.ykf.eureka.provide.main.entry.User;
public interface UserMapper {
User findUser(Integer id);
int saveUser(User user);
int deleteUser(Integer id);
}
7:然后是mybatis的 mapper文件
UserMapper.xml
insert into user(uname,pwd)
values(#{uname},#{pwd})
delete from user where id
= #{id}
8:然后在是 controller控制层
package spring.cloud.ykf.eureka.provide.main.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import spring.cloud.ykf.eureka.provide.main.entry.User;
import spring.cloud.ykf.eureka.provide.main.service.UserService;
/**
*/
@RestController
public class UserController {
@Autowired
UserService userService;
@RequestMapping(value = "/query/{id}")
public User findByIdUser(@PathVariable("id") Integer id) {
User us = userService.findUser(id);
return us;
}
@RequestMapping(value = "/del/{id}")
public String delUser(@PathVariable("id") Integer id) {
int num = userService.deleteUser(id);
return num == 1 ? "succ" : "err";
}
@RequestMapping(value = "/save/{uname}/{pwd}")
public String delUser(@PathVariable("uname") String uname, @PathVariable("pwd") String pwd) {
User user = new User();
user.setPwd(pwd);
user.setUname(uname);
int num = userService.saveUser(user);
return num == 1 ? "succ" : "err";
}
}
http://www.namhuy.net/475/how-to-install-gui-to-centos-minimal.html
I have centos 6.3 minimal running as web server. I’m looking to install gui to my server to vnc to my server. You can insta
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'option,changed_ids ) values('0ac91f167f754c8cbac00e9e3dc372
实例1:
package com.bijian.thread;
public class MyThread extends Thread {
private static ThreadLocal tl = new ThreadLocal() {
protected synchronized Object initialValue() {
return new Inte
var v = 'C9CFBAA3CAD0';
console.log(v);
var arr = v.split('');
for (var i = 0; i < arr.length; i ++) {
if (i % 2 == 0) arr[i] = '%' + arr[i];
}
console.log(arr.join(''));
console.log(v.r