亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

? Java java?? ?? ??? ?? ?? ??

??? ?? ?? ??

Nov 26, 2024 am 12:37 AM

Spring Boot Cheat Sheet

??? ?? ?? ??

??

Annotation Description Example
@SpringBootApplication Marks a class as a Spring Boot application. Enables auto-configuration and component scanning. @SpringBootApplication
@RestController Indicates that a class provides RESTful endpoints. It combines @Controller and @ResponseBody annotations. @RestController
@RequestMapping Maps HTTP requests to handler methods of RESTful controllers. @RequestMapping("/api")
@Autowired Injects dependencies into a Spring bean. It can be used for constructor, setter, or field injection. @Autowired private MyService myService;
@Component Indicates that a class is a Spring-managed component. It is automatically detected during component scanning. @Component
@Repository Marks a class as a Spring Data repository. It handles data access and persistence logic. @Repository
@Service Marks a class as a service component in the business layer. It is used to separate business logic from presentation logic. @Service
@Configuration Indicates that a class provides bean definitions. It is used along with @bean to define beans in Java-based configuration. @Configuration
@Value Injects values from properties files or environment variables into Spring beans. @Value("${my.property}") private String property;

?? ??

  1. ???: Spring Boot? ?????? ??? ???? Bean? ?? ???? ?????.
  2. ???? ??: ????, ???, ???? ?? ????? ?? Spring ??
  3. ? ??: Spring? ??? ??? ???? ?? ???? ???? ?????.
  4. ?? ??: ???? HTTP ??? ?? ??? ???? ???? ???? ?????.
  5. ??: ???? ???? ??? ???? ???? ?? ???? ??? ?????.
  6. ?? ???: Spring? ??? ?? ?? ??? HTTP ??(?: JSON)?? ?????.

?? ?? ??

src
├── ??
│ ├── ??
│ │ └── com
│ │ └── ??
│ │ ├── ????
│ │ │ └── MyController.java
│ │ ├── ???
│ │ │ └── MyService.java
│ │ └── Application.java
│ └── ???
│ ├── ??????.??
│ └── ???
│ └── index.html
└── ???
└── ??
└── com
└── ??
└── ????
└── MyControllerTest.java

Spring Boot ?? ??? ?? ??

?? ??? ??? ??????? ???? ? ?? ??? ?????. Spring Boot? ??? ??? ???? ???? ?? ?? ????? ???? ??? ??? ??? ?????.

?? ??

  • ????? ??: 400 ??? ?? ?? 404 ?? ? ?? ? ??? ????? ???? ?? ??? ?????.
  • ?? ??: 500 ?? ?? ?? ? ?? ??? ???? ?????.
  • ?? ??: ??? ?? ?? ??? ?? ??? ?? ??

?? ?? ????

1. ???? ??

  • @ControllerAdvice: Spring MVC?? ?? ?? ???? ???? ? ???? ?????.
  • @ExceptionHandler: ???? ?? ??? ?? ??? ???? ? ???? ?????.
  • ?:
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(MyException.class)
    public ResponseEntity<ErrorResponse> handleMyException(MyException ex) {
        ErrorResponse response = new ErrorResponse("My error message");
        return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
    }

    @ExceptionHandler(Exception.class)
    public ResponseEntity<ErrorResponse> handleException(Exception ex) {
        ErrorResponse response = new ErrorResponse("Internal server error");
        return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR);
    }
}

ResponseEntityExceptionHandler

  • ResponseEntityExceptionHandler: ???? Spring MVC ??? ???? ?? ?? ??????.
  • ???: handlerMethodArgumentNotValid, handlerHttpMessageNotReadable ?? ?? ???? ??????.
  • ?:
@ControllerAdvice
public class CustomExceptionHandler extends ResponseEntityExceptionHandler {

@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(
        MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) {
    ErrorResponse response = new ErrorResponse("Validation failed");
    return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
}

// Other overrides for handling specific exceptions

3. ?? ??

  • ErrorAttributes: ?? ??? ??? ??? ??? ???? ? ???? ????????.
  • DefaultErrorAttributes: Spring Boot?? ???? ?? ?????.
@Component
public class CustomErrorAttributes extends DefaultErrorAttributes {
@Override
public Map<String, Object> getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) {
    Map<String, Object> errorAttributes = super.getErrorAttributes(webRequest, includeStackTrace);
    errorAttributes.put("customAttribute", "Custom value");
    return errorAttributes;
}

}

?? ?? ??

  • application.properties: ?? ??, ?????? URL ?? ?? ?????? ?? ??? ?????.
  • ??? ?? ?? ??: ??? ??? ?? ??? ?? ?? ??? ?????(?: application-dev.properties).
  • ?? ???: @Value ?? ?? Spring? Environment API? ???? ??? ??????.

?? ????

  • Maven: mvn clean install? ???? ????? ???? ?? ??? JAR? ?????.
  • Gradle: ./gradlew build? ???? ????? ???? ?? ??? JAR? ?????.

?? ??

  • Spring Boot Starters: ???? ???? ????? ???? ?? ??? ?????.
  • ??: Logback, Log4j ?? Java Util Logging? ???? ??? ?????.
  • ?? ??: @ControllerAdvice? ???? ?? ?? ??? ?????.
  • ???: JUnit, Mockito ? SpringBootTest? ???? ?? ??? ? ?? ???? ?????.

? ??? ??? ?? ?? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1597
29
PHP ????
1488
72
???
?? ??? ??? ????? ?? ?? ??? ??? ????? ?? Jul 07, 2025 am 02:24 AM

Java? ??? ?? ??, ?? ? ??? (? : Projectreactor) ? Java19? ?? ???? ??? ??? ?????? ?????. 1. CompletableFuture? ?? ??? ?? ?? ??? ? ?? ??? ????? ?? ??????? ? ?? ??? ?????. 2. Projectreactor? ?? ? ??? ??? ???? ?? ???? ? ??? ???? ?? ? ?????? ?????. 3. ?? ???? ??? ??? ??? I/O ??? ? ??? ???? ?? ??? ????? ??? ???? ????. ? ???? ?? ??? ????? ??? ??? ??? ?? ??? ??? ?????? ???? ???? ?? ?? ??? ??????.

???? ??? ?????? ?? ?? ???? ??? ?????? ?? ?? Jul 07, 2025 am 02:35 AM

Java?? ??? ?? ?? ??? ???? ? ?????. ?? ???? ??? ?????. 1. ?? ?? ? ???? ??????? ?? ?? ?? ??? ???? ??? ?????. 2. ?? ??, ???, ??? ?? ?? ?? ???? ????? ?? ??? ??? ??? ?????. 3. ENUMMAP ? ENUMSET? ???? ?? ? ?? ???? ???? ??? ???? ? ?????? ?????. 4. ?? ?, ??? ?? ?? ??? ?? ????? ?? ??? ??? ?????.? ????? ?? ???? ????????. ??? ???? ???? ?? ??? ????? ??? ?? ? ??? ?? ?????? ???????.

Java Nio? ? ??? ????? Java Nio? ? ??? ????? Jul 08, 2025 am 02:55 AM

Javanio? Java 1.4? ?? ? ??? IOAPI???. 1) ?? ? ??? ?????, 2) ??, ?? ? ??? ?? ?? ??, 3) ? ??? ??? ???? 4) ?? ??? ?? IO?? ? ????? ?????. 1) ? ?? IO? ??? ?? ??? ???, 2) ??? ??? ?? ???? ?????, 3) ???? ?????? ???? 4) ??? ?? ??? ?? ?? ? ??? ?????. 1) ??? ??/??? ??? ?? ?????, 2) ???? ???? ???? ?? ???? ???????. 3) ??? ??? ??? ???????.

Java ??? ??? ????? ???? ?? Java ??? ??? ????? ???? ?? Jul 06, 2025 am 02:53 AM

Java? ????? ????? ??? ??? ?? ???? ?? ?? ??????, ?? ? ???? ? ??? ????. ?? ???? ??? ??? ???? ??? ??? ???? ?? ??? ??? ????. ???? ???? ??? ??, ?? ??? ???? ???? ?? ??? ?? ???? ?? ?????. ???? ?? ?? ??? ?? ?? ??? ?????. ?????? ?? ??? ??? ???? ?? ??? ??? ?? ??? ???? ???? ??? ?? ??? ?????? ???? ????? ??? ?? ?? ???, ?? ? ?? ???? ??? ??? ?????. ???? urlclassl? ?? ??? ??? ??? ?? ? ? ????

???? Java ??? ????? ????? ???? Java ??? ????? ????? Jul 05, 2025 am 02:35 AM

Java ?? ??? ??? ?? ? ??? ???? ?? ??? ???? Try-Catch? ???? ????? ????? ???? ????. 1. IoException? ?? ?? ? ??? ???? ?? ??? ??? ?? ???????. 2. NullPointerException? ?? ???? ?? ??? ????? ???? ?? ??? ?? ???? ??? ?????. 3. ??? ?? ? ?? ??? ???? ??? ??? ?? ????? ???????. 4. CODE? ?? ??? ??? ?? ??? ???? ??? ???? ??? ???? ?? ?? ????. 5. ?? ???? ??? ??? ?? ??? ??? ?? ???? ??? ???????.

?? ?? ???? ????? ??? ?????? ?? ?? ???? ????? ??? ?????? Jul 15, 2025 am 03:10 AM

?? ?? Java? ?? ???? ?? ? ? ? ????? ????, ? ??? ??? ??? ??? ???? ? ????. 1. ?? ?? hashcode () ???? ???? ?? ?? ???? ?? ??? ?? ?? ???? ?????. 2. ?? ??? ??? ?? ?? ???? ??? ??? ? ????. ?? ??? ?? ? ??? ??? ?????. JDK8 ? ?? ? ??? ?? ?? (?? ?? 8) ??? ????? ?? ???? ?? ? ??? ?????. 3. ??? ?? ???? ?? ???? ?? equals () ? hashcode () ???? ?? ???????. 4. ?? ?? ??? ???? ?????. ?? ?? ??? ???? ?? ?? (?? 0.75)? ??? ?? ? ???; 5. ?? ?? ??? ??? ??? Multithreaded?? Concu? ???????.

?? : ?? ?? ?????? Java ??? ?? : ?? ?? ?????? Java ??? Jul 05, 2025 am 02:52 AM

???? Java ?? ?? ?????? ?? ?? ? ?????. ??? "??? ?????, ?? ??"? ????. ??, ??? ? ?? ? ?? ??? ?? ?? ??? ??? ???? ?? ?? ? ?????? ?????. 1. ???? ?? ???? ?? ??? ??? ?? ? ?????, ?? ??? ??? ?? ?? ??? ?? ?????. 2. ??? ?? ??, ?? ? ?? ? ?? ??? ? ?? ??? ??????. 3. ?? ?? ?? ??? ??, ??? ?? ? ??? ?? ??? ???? ???? ? ?????. 4. ???? ?? ???? ?? ?? ? ??? ? ?? ? ? ????. ?? ???? ?? ? ??? ??? ????? ???? ??????? ?? ?????? ???????.

Java ?? ? ?? ??? ???? ?? Java ?? ? ?? ??? ???? ?? Jul 07, 2025 am 02:43 AM

Java ??? ??? ???? ??? ??? ??? ?????, ???? ????, ?????? ??? ? ????. 1. ??? ????? ???? ??? ? ? ??? ?? ?? ????? ???? ? ???? ??????. 2. ???? ?? ?? ???? ??? ??? ???? ?? ?? ???? ??? ??? ? ????. 3. ???? ???? ??? ??? ?? ??? ?? ? ? ??????. 4. ?? ?? ?? ??? ? ??? ??? ?? ????? ?? ?? ??? ??? ? ????. 5. ??, ?? ?? ??, ?? ?? ?? ???, ????? ?? ?? ? ???? ??? ????? ??????.

See all articles