Hello,SpringBoot

注意点:
SpringBoot一旦用上,jdk最少1.8
ssm一般使用1.7
1.新建Spring Initializr工程,下一步,勾选依赖

在这里插入图片描述
2.applicaton.xml修改后缀为yml,官方推荐使用

server:
  port: 9000
spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/oa
    username: root
    password: abc123
mybatis:
  type-aliases-package: com.njbdqn.pojo
  mapper-locations: mapper/*.xml

3.新建pojo,dao,service(service层上加注解@Service)
4.新建controller
知识点:
@RestController:返回值是json格式
@CrossOrigin("*"):跨域问题开放端口

@RestController
@CrossOrigin("*")
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;

    @RequestMapping("/init")
    public List<Employee> getAll(){
        return employeeService.getAll();
    }
}

5.MysptApplication类上添加注解@MapperScan(“com.njbdqn.dao”)
相当于ssm配置MapperScannerConfigurer,自动生成dao代理对象

@SpringBootApplication
@MapperScan("com.njbdqn.dao")
public class MysptApplication {

	public static void main(String[] args) {
		SpringApplication.run(MysptApplication.class, args);
	}
}

猜你喜欢

转载自blog.csdn.net/qq_39905910/article/details/84316777
今日推荐