org.springframework.boot
spring-boot-starter-parent
1.2.5.RELEASE
–>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<openjpa.version>3.1.0</openjpa.version>
<spring.boot.version>1.2.5.RELEASE</spring.boot.version>
<spring.version>4.2.1.RELEASE</spring.version>
org.springframework.boot
spring-boot-starter-data-jpa
${spring.boot.version}
hibernate-entitymanager
org.hibernate
org.springframework.boot
spring-boot-starter-logging
${spring.boot.version}
org.apache.openjpa
openjpa-all
${openjpa.version}
system
${project.basedir}/libs/openjpa-all-3.1.0.jar
com.gbase
gbasedbtjdbc
1.0
system
${project.basedir}/libs/gbasedbtjdbc.jar
org.springframework.boot
spring-boot-starter-test
${spring.boot.version}
test
org.springframework.boot
spring-boot-starter-web
${spring.boot.version}
org.apache.maven.plugins
maven-compiler-plugin
3.1
${java.version}${java.version}
${project.build.sourceEncoding}
-Xlint:all
true
org.springframework.boot
spring-boot-maven-plugin
${spring.boot.version}
org.springframework
springloaded
1.2.4.RELEASE
org.springframework
spring-instrument
${spring.version}
s e t t i n g s . l o c a l R e p o s i t o r y / o r g / s p r i n g f r a m e w o r k / s p r i n g − i n s t r u m e n t / {settings.localRepository}/org/springframework/spring-instrument/ settings.localRepository/org/springframework/spring−instrument/{spring.version}/spring-instrument-${spring.version}.jar
s e t t i n g s . l o c a l R e p o s i t o r y / o r g / a p a c h e / o p e n j p a / o p e n j p a / {settings.localRepository}/org/apache/openjpa/openjpa/ settings.localRepository/org/apache/openjpa/openjpa/{openjpa.version}/openjpa-${openjpa.version}.jar
org.apache.openjpa
openjpa-maven-plugin
${openjpa.version}
**/entity/*.class
true
true
src/main/resources/schema.sql
src/main/resources/META-INF/persistence.xml
enhancer
process-classes
enhance
jpa配置,创建persistence.xml
放在 src\main\resources\META-INF
下
<persistence version=“1.0”
xmlns=“http://java.sun.com/xml/ns/persistence” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
org.apache.openjpa.persistence.PersistenceProviderImpl
wang.datahub.example.entity.Userinfo
<property name=“openjpa.ConnectionURL”
value=“jdbc:gbasedbt-sqli://172.24.110.229:90881/t1:GBASEDBTSERVER=ol_gbasedbt1210_1;NEWCODESET=UTF8,zh_cn.UTF8,57372;DATABASE=t1;DB_LOCALE=en_US.819;”/>
<property name=“openjpa.ConnectionDriverName”
value=“com.gbasedbt.jdbc.Driver”/>
<property name=“openjpa.ConnectionUserName”
value=“gbasedbt”/>
<property name=“openjpa.ConnectionPassword”
value=“dafei1288”/>
系统配置application.yml
server:
port: 8088
context-path: /
#spring-jpa-data数据库配置信息 org.springframework.boot.autoconfigure.jdbc.DataSourceProperties
spring:
jpa:
show-sql: true
generate-ddl: true
hibernate:
ddl-auto: create-drop
datasource:
driver-class-name: com.gbasedbt.jdbc.Driver
url: jdbc:gbasedbt-sqli://172.24.110.229:9088/t1:GBASEDBTSERVER=ol_gbasedbt1210_1;NEWCODESET=UTF8,zh_cn.UTF8,57372;DATABASE=t1;DB_LOCALE=en_US.819;
username: gbasedbt
password: dafei1288
创建实体类:
package wang.datahub.example.entity;
import javax.persistence.*;
@Entity
@Table
public class Userinfo {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column
private String username;
@Column
private int age;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return “Userinfo{” +
“id='” + id + ‘’’ +
“, username='” + username + ‘’’ +
“, age=” + age +
‘}’;
}
}
创建UserinfoRepository
用于完成持久化操作
package wang.datahub.example.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import wang.datahub.example.entity.Userinfo;
@Repository
public interface UserinfoRepository extends JpaRepository<Userinfo, String> {
}
创建UserinfoService
接口,以及其实现类,这里仅以增加记录和查询记录为例:
package wang.datahub.example.service;
import wang.datahub.example.entity.Userinfo;
import java.util.List;
public interface UserinfoService {
List getAll();
Userinfo saveOne(Userinfo userinfo);
}
UserinfoServiceImpl实现
package wang.datahub.example.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import wang.datahub.example.entity.Userinfo;
import wang.datahub.example.repository.UserinfoRepository;
import wang.datahub.example.service.UserinfoService;
import java.util.List;
@Service
public class UserinfoServiceImpl implements UserinfoService {
@Autowired
private UserinfoRepository userinfoRepository;
@Override
public List getAll(){
return userinfoRepository.findAll();
}
@Override
public Userinfo saveOne(Userinfo userinfo){
System.out.println(userinfo);
return userinfoRepository.saveAndFlush(userinfo);
}
}
创建Rest接口 UserinfoController
package wang.datahub.example.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import wang.datahub.example.entity.Userinfo;
import wang.datahub.example.service.UserinfoService;
import java.util.List;
@RestController
public class UserinfoController {
@Autowired
private UserinfoService userinfoService;
@RequestMapping(value = “/userinfo”, method = RequestMethod.GET)
public List getAll(){
return userinfoService.getAll();
}
@RequestMapping(value=“/userinfo”,produces = “application/json;charset=UTF-8”, method = RequestMethod.POST)
public Userinfo save(@RequestBody Userinfo userinfo){
return userinfoService.saveOne(userinfo);
}
}
创建启动类 App
package wang.datahub.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter;
import org.springframework.transaction.jta.JtaTransactionManager;
import javax.persistence.spi.PersistenceProvider;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)
![img](https://i-blog.csdnimg.cn/blog_migrate/be197e62f730da7e9ff19d6bc74d6ae3.jpeg)
分享
首先分享一份学习大纲,内容较多,涵盖了互联网行业所有的流行以及核心技术,以截图形式分享:
(亿级流量性能调优实战+一线大厂分布式实战+架构师筑基必备技能+设计思想开源框架解读+性能直线提升架构技术+高效存储让项目性能起飞+分布式扩展到微服务架构…实在是太多了)
其次分享一些技术知识,以截图形式分享一部分:
Tomcat架构解析:
算法训练+高分宝典:
Spring Cloud+Docker微服务实战:
最后分享一波面试资料:
切莫死记硬背,小心面试官直接让你出门右拐
1000道互联网Java面试题:
Java高级架构面试知识整理:
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
=“https://i-blog.csdnimg.cn/blog_migrate/be197e62f730da7e9ff19d6bc74d6ae3.jpeg” alt=“img” style=“zoom: 33%;” />
分享
首先分享一份学习大纲,内容较多,涵盖了互联网行业所有的流行以及核心技术,以截图形式分享:
(亿级流量性能调优实战+一线大厂分布式实战+架构师筑基必备技能+设计思想开源框架解读+性能直线提升架构技术+高效存储让项目性能起飞+分布式扩展到微服务架构…实在是太多了)
其次分享一些技术知识,以截图形式分享一部分:
Tomcat架构解析:
[外链图片转存中…(img-qOwUQQcV-1713306342944)]
算法训练+高分宝典:
[外链图片转存中…(img-7rSRmfXY-1713306342945)]
Spring Cloud+Docker微服务实战:
[外链图片转存中…(img-Fu5l88mb-1713306342945)]
最后分享一波面试资料:
切莫死记硬背,小心面试官直接让你出门右拐
1000道互联网Java面试题:
[外链图片转存中…(img-1z2Qgis0-1713306342945)]
Java高级架构面试知识整理:
[外链图片转存中…(img-KuToWMbm-1713306342945)]
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!