springboot学习

@SpringBootApplication:主程序注解

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

@Controller

@ResponseBody:写出到浏览器

=@RestController

@RequestMapping("/hello"):接受url /hello请求

@Controller
public class HelloController {

   @ResponseBody
   @RequestMapping("/hello")
   public String hello() {
       return "Hello world";
  }
}

打包

<!--部署代码-->
   <build>
       <plugins>
           <plugin>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-maven-plugin</artifactId>
           </plugin>
       </plugins>
   </build>

 

 

 

 

@Component, @Service, @Controller, @Repository是spring注解,注解后可以被spring框架所扫描并注入到spring容器来进行管理 @Component是通用注解,其他三个注解是这个注解的拓展,并且具有了特定的功能 @Repository注解在持久层中,具有将数据库操作抛出的原生异常翻译转化为spring的持久层异常的功能。 @Controller层是spring-mvc的注解,具有将请求进行转发,重定向的功能。 @Service层是业务逻辑层注解,这个注解只是标注该类处于业务逻辑层。

 

 

毕业设计:

  1. Mapper的xml文件是sql语句,通过id与mapper java文件关联

  2. 导入学院系excel文件功能

原文地址:https://www.cnblogs.com/0710whh/p/12248986.html