Java? ???? Spring Data ?? ?????? ??? ??????? ???? ??
Sep 20, 2023 pm 03:27 PMJava? ???? Spring Data ?? ?????? ??? ??????? ???? ??
??:
??? ????? ?? ???? ??????? ???? ? ? ?????. ??????? ?????? ???? ?? ?? ??? ???? ?? ??? ????. ?? ???? ?? ??? ????? ?? Spring Data? ??????. Spring Data? ??? ??? ???? ???? ??? ??? ?? ?? ??????? ?? ???? ???? ????????.
? ????? Java? ???? Spring Data ?? ?????? ??? ??????? ???? ??? ?????. MySQL? ??????? ???? Spring Data JPA? ?? ??? ??? ??? ?????.
1??: ?? ?? ??
- Java JDK ? ?????? MySQL? ???? ?? ?? ??? ?????.
-
??? Maven ????? ???? ?? ???? ???? Spring Data ? MySQL? ?? ??? ?????. ????? pom.xml ??? ?? ???? ?????.
<dependencies> <!-- Spring Data JPA --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <!-- MySQL驅(qū)動 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.26</version> </dependency> </dependencies>
Spring Boot ?????? ?? ???? ???? ??? ?? ?? ??? ?????.
@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
2??: ?????? ?? ??
Spring Boot?? ?? ?? application.properties?? ??????? ?? ??? ??? ?? ?????.
spring.datasource.url=jdbc:mysql://localhost:3306/testdb spring.datasource.username=root spring.datasource.password=root spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
??? ??????? URL, ??? ??, ????? ???? MySQL8 ??? ???? ???? ?????.
3??: ??? ??? ???
??????? ???? ??? ???? ??? ???? ????. ? ???? ??? ?? id, name, age?? ? ?? ??? ???? User ??? ???? ?????.
@Entity @Table(name = "user") public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(name = "name") private String name; @Column(name = "age") private Integer age; // getter和setter方法 }
????? JPA ??? ???? ??? ???? ?? ?? ?? ??? ?????.
4??: ??? ??? ????? ??
??????? ?? ??? ???? ?????? ?????. ? ???? ??? ?? Spring Data JPA? CrudRepository ?????? ???? UserRepository ?????? ?????.
public interface UserRepository extends CrudRepository<User, Long> { List<User> findByName(String name); }
????? CrudRepository ?????? ???? ?? ??? ???? ???? ?? ??? ?????.
5??: ??? ?? ??
?????? ??? ???? ???? ??? ??? ??? ???. ? ???? ??? ?? UserService ???? ???? UserRepository? ???? ??? ??? ??? ?????.
@Service public class UserService { @Autowired private UserRepository userRepository; public User save(User user) { return userRepository.save(user); } public User findById(Long id) { return userRepository.findById(id).orElse(null); } public List<User> findByName(String name) { return userRepository.findByName(name); } }
????? Autowired ??? ???? UserRepository? ???? ???? ID ???? ???? ???? ???? ??? ?????. ???? ???? ?? ??? ???? ???? ????.
6??: ?????? ??
?? ???? ?? ????? Spring Boot ??????? ?????.
public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
? ???? ??????? ???? http://localhost:8080? ????? ??????? ???? ? ????.
??:
? ????? Java? ???? Spring Data ?? ?????? ??? ??????? ???? ??? ?????. ??? Spring Data JPA? ???? MySQL ??????? ?? ???? ???? ??? ???, ??? ??? ????? ? ??? ??? ???? ??? ??????. Spring Data? ???? ??? ?? ?? ?? ??? ???? ?? ???? ?? ??? ???? ? ????. ? ??? ??? ??? ????!
? ??? Java? ???? Spring Data ?? ?????? ??? ??????? ???? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

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

JDBC ????? ???? ????? ?? ?? ?? ??? ?? ?? ??? ?? ? ?? ??? ?? ?? ?? ??? ???????. 1. ????? ????? Conn.SetAutoCommit (False)?? ??????. 2. ??? ? ????? ?? ?? SQL ??? ?????. 3. ?? ??? ??? ?? Conn.commit ()?? ???? ??? ???? ???? ?? ??? ???? Conn.Rollback ()?? ??????. ???, ? ??? ???? ????, ??? ???? ????, ?? ??? ??? ?? ??? ??? ???? ? ???????. ?? ?? ?? ???? ????? ??? ???? ?? ?? ???? ???? ??? ????? ?? ??? ??? ? ?? ???? ?? ????.

thejvmenablesjava? "WriteOnce, Runynywhere"??? ?? excodecodethroughfourmaincomponents : 1. theclassloadersubsystemloads, ??, ? intinitializes.classfilesusingbootsprap, extension, andapplicationclassloaders, ensuringsecureandlazyclasloa

?? ?? ? ?? ???? ???? ?? Java.Time ???? ???? ??????. 2. LocalDate, LocalDateTime ? LocalTime? ?? ?? ??? ??? ?????. 3. () ???? ???? ?? ??? ??? ????. 4. ???/???? ??? ???? ??? ????? ??? ??????. 5. ZonedDateTime ? Zoneid? ???? ???? ??????. 6. DateTimeFormatter? ?? ?? ? ?? ?? ?? ???; 7. ??? ?? ?? ?? ??? ????? ?? ??????. ?? Java? ?? ??? ???? ??? ??? ???? Java.Timeapi ??? ?? ??? ???????.

Pre-FormancetArtUptimeMoryUsage, Quarkusandmicronautleadduetocompile-timeprocessingandgraalvsupport, withquarkusoftenperforminglightbetterine serverless sinarios.2.thyvelopecosyste,

NetworkPortSandfirewallsworkTogetToenableCommunication whileensuringsecurity.1.networkportSarevirtualendpointsnumbered0–65535, Withwell-nownports like80 (http), 443 (https), 22 (ssh) ? 25 (smtp) ?? (specservices

Java 's Garbage Collection (GC)? ???? ???? ???? ??????, ?? ? ??? ??? ? ??? ??? ??? ??? ????. 1.GC? ?? ?? (? : ?? ??, ?? ???, ?? ?? ?)?? ??? ???? ????, ?? ? ??? ??? ???? ?????. 2. ?? ???? ????? ????, ?? ?? ??? ??? ???? ?? ??? ??????. 3. ?? ?? ?? ?? : ??? ?? (Eden, S0, S1)? ?? ????? ?????. ??? ??? ?? ? MajorGC? ???? ? ??? ? ????. Metaspace? ??? ?? ???? ?????. 4. JVM? ??? GC ??? ?????. SerialGC? ??? ?? ????? ?????. ParallelGC? ???? ??????. CMS? ?? ???

GradleisBetTerChoiceFormostNewProjectSduetoitssuperiorflexible, Performance, and ModernToolingsupport.1.Gradle'Sgroovy/kotlindslismoreConcisENDEXPRESSIVETHANMAVEN'SVOSEXML.2.GradleOutsMaveninbuildweedweedweedweedweedweedweedweedweedweedweedweedweedweede

DEFER? ??? ???? ?? ??? ??? ???? ? ?????. ?? ??? ?? ? ? ?? ????, ??? ??? ? ?? ?? (LIFO)? ??? ?????. 1. ?? ??? ??? ? ??? ?????. 2. ?? ??? ?? ??? ??? ????? ?????. 3. ?? ? ?? ?? ??? ? ????. 4. ??? ?????? ??? ??? ???? ?????. 5. ?? ??? ???? ?? ??? ?? ??? ?????. ??? ??? ?? ?? ? ???? ???? ? ????.
