}
public void setAge(Integer age) {
this.age = age;
}
}
此模块,主要存放业务接口的定义,它是服务消费者模块和服务提供者模块的公共依赖模块
<?xml version="1.0" encoding="UTF-8"?><project xmlns=“http://maven.apache.org/POM/4.0.0”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
dubbo_parent
com.lichun
1.0-SNAPSHOT
4.0.0
dubbo_interface
jar
com.lichun
dubbo_common
1.0-SNAPSHOT
UserService.java
package com.lichun.service;
import com.lichun.pojo.User;
public interface UserService {
User findById(Integer id);
}
只要能启动spring的容器(加载spring的配置文件)就可以启动项目,因此有三种启动项目方式:
ClassPathXmlApplication
监听器
DispatcherServlet
注册中心验证:
注意:
消费者与提供者应用名称不能相同
如果有多个服务提供者,名称不能相同,通信端口也不能相同
只有服务提供者才会配置服务发布的协议,默认是dubbo协议,端口号是20880
<dubbo:protocol name=“dubbo” port=“20881”></dubbo:protocol>
pom.xml
<?xml version="1.0" encoding="UTF-8"?><project xmlns=“http://maven.apache.org/POM/4.0.0”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
dubbo_parent
com.lichun
1.0-SNAPSHOT
4.0.0
dubbo_provider
war
com.lichun
dubbo_interface
1.0-SNAPSHOT
org.springframework
spring-webmvc
com.alibaba
dubbo
org.apache.zookeeper
zookeeper
org.apache.curator
curator-framework
org.apache.curator
curator-recipes
org.mybatis
mybatis
org.mybatis
mybatis-spring
com.alibaba
druid
mysql
mysql-connector-java
org.springframework
spring-tx
org.springframework
spring-jdbc
org.slf4j
slf4j-log4j12
UserDao.java
package com.lichun.dao;
import com.lichun.pojo.User;
import org.apache.ibatis.annotations.Select;
public interface UserDao {
@Select(“select * from t_user where id = #{id}”)
User findById(Integer id);
}
UserServiceImpl.java
package com.lichun.service.impl;
import com.lichun.dao.UserDao;
import com.lichun.pojo.User;
import com.lichun.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
public class UserServiceImpl implements UserService {
@Autowired
UserDao userDao;
@Override
public User findById(Integer id) {
User user = userDao.findById(id);
return user;
}
}
MyApplicationContext.java
package com.lichun;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.io.IOException;
public class MyApplicationContext {
public static void main(String[] args) throws IOException {
new ClassPathXmlApplicationContext(“classpath:spring-provider.xml”);
System.in.read();
}
}
log4j.properties
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.err
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug, stdout
spring-dao.xml
配置数据源
配置sqlSessionFactory对象
扫描dao包,创建dao接口的动态代理对象
<beans xmlns=“http://www.springframework.org/schema/beans”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
spring-service.xml
<beans xmlns=“http://www.springframework.org/schema/beans”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:tx=“http://www.springframework.org/schema/tx”
xsi:schemaLocation=“http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd”>
<tx:annotation-driven transaction-manager=“txManager”/>
spring-provider.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns=“http://www.springframework.org/schema/beans”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:dubbo=“http://dubbo.apache.org/schema/dubbo”
xsi:schemaLocation=“http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd”>
<dubbo:application name=“dubbo_provider”/>
<dubbo:registry address=“zookeeper://127.0.0.1:2181”/>
<dubbo:service interface=“com.lichun.service.UserService” ref=“userService”/>
web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xmlns=“http://java.sun.com/xml/ns/javaee”
xsi:schemaLocation=“http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd”
version=“2.5”>
contextConfigLocation
classpath:spring-provider.xml
org.springframework.web.context.ContextLoaderListener
pom.xml
<?xml version="1.0" encoding="UTF-8"?><project xmlns=“http://maven.apache.org/POM/4.0.0” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
dubbo_parent
com.lichun
1.0-SNAPSHOT
4.0.0
dubbo_consumer
war
com.lichun
dubbo_interface
1.0-SNAPSHOT
org.springframework
spring-webmvc
com.fasterxml.jackson.core
jackson-core
2.9.0
com.fasterxml.jackson.core
jackson-databind
2.9.0
com.fasterxml.jackson.core
jackson-annotations
2.9.0
javax.servlet
servlet-api
2.5
provided
com.alibaba
dubbo
org.apache.zookeeper
zookeeper
org.apache.curator
curator-framework
org.apache.curator
curator-recipes
org.slf4j
slf4j-log4j12
UserController.java
package com.lichun.controller;
import com.lichun.pojo.User;
import com.lichun.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(“/user”)
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(“/findById”)
public User findById(Integer id) {
// springmvc默认使用jaskson来解析java对象为json字符串,注意引入jaskson的依赖
return userService.findById(id);
}
}
log4j.properties
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.err
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug, stdout
spring-consumer.java
<?xml version="1.0" encoding="UTF-8"?><beans xmlns=“http://www.springframework.org/schema/beans”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xmlns:context=“http://www.springframework.org/schema/context” xmlns:dubbo=“http://dubbo.apache.org/schema/dubbo”
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
<dubbo:application name=“dubbo_consumer”/>
<dubbo:registry address=“zookeeper://127.0.0.1:2181”/>
<dubbo:reference interface=“com.lichun.service.UserService” id=“userService”/>
<dubbo:consumer check=“false” timeout=“2000” retries=“2”/>
spring-mvc.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns=“http://www.springframework.org/schema/beans”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xmlns:context=“http://www.springframework.org/schema/context”
xmlns:mvc=“http://www.springframework.org/schema/mvc”
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package=“com.lichun.controller”/>
mvc:annotation-driven/
web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xmlns=“http://java.sun.com/xml/ns/javaee”
xsi:schemaLocation=“http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd”
version=“2.5”>
dispatcherServlet
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)
以上是字节二面的一些问题,面完之后其实挺后悔的,没有提前把各个知识点都复习到位。现在重新好好复习手上的面试大全资料(含JAVA、MySQL、算法、Redis、JVM、架构、中间件、RabbitMQ、设计模式、Spring等),现在起闭关修炼半个月,争取早日上岸!!!
下面给大家分享下我的面试大全资料
后端JAVA面试大全
MySQL+Redis学习笔记算法+JVM+JAVA核心知识整理
MySQL+Redis学习笔记算法+JVM+JAVA核心知识整理
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。**[外链图片转存中…(img-5SQNkyUR-1713415756980)]
[外链图片转存中…(img-iEyL2vrn-1713415756980)]
[外链图片转存中…(img-CljwP9ok-1713415756980)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)
以上是字节二面的一些问题,面完之后其实挺后悔的,没有提前把各个知识点都复习到位。现在重新好好复习手上的面试大全资料(含JAVA、MySQL、算法、Redis、JVM、架构、中间件、RabbitMQ、设计模式、Spring等),现在起闭关修炼半个月,争取早日上岸!!!
下面给大家分享下我的面试大全资料
[外链图片转存中…(img-eSl0mr2T-1713415756981)]
后端JAVA面试大全
[外链图片转存中…(img-vUWJgNBo-1713415756981)]
MySQL+Redis学习笔记算法+JVM+JAVA核心知识整理
[外链图片转存中…(img-fuDiiCXS-1713415756981)]
MySQL+Redis学习笔记算法+JVM+JAVA核心知识整理
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
文章浏览阅读185次。final Intent intent=new Intent(this,Servicetest1.class)位置放到onCreate()外面,那么就会出现闪退。如果在调试的时候闪退,很可能是语句的位置出现了问题,至今位置我发生过2次闪退,2次都是语句位置不对。我觉得那个时候Sercicetest1.class类可能还没有加载完吧。首先:语句没有问题,可以通过编译,那么就是位置不对了-----逻辑问题。例如如果把这个里面的。
文章浏览阅读1.4k次。四种引用在Java 1.2 之后,Java地引用的概念进行了补充,以前只有被引用和没有被引用两种状态。扩充之后分为四种,1. 强引用(Strong Reference)2. 软引用(Soft Reference)3. 弱引用(WeakReference)4. 虚引用(Phantom Reference),也称幽灵引用或者幻影引用_java中的四种引用关系由强到弱 site:blog.csdn.net
文章浏览阅读1k次,点赞2次,收藏8次。1、C++类对象的内存布局 在C++的类对象中,有两种类的成员变量:static和非static,有三种成员函数:static、非static和virtual。那么,它们在C++的内存中是如何分布的呢? C++程序的内存格局通常分为四个区:全局数据区(data area),代码区(code area),栈区(stack ..._类的内存布局
文章浏览阅读2.8k次。Gene Ontology可分为分子功能(Molecular Function),生物过程(biological process)和细胞组成(cellular component)三个部分。蛋白质或者基因可以通过ID对应或者序列注释的方法找到与之对应的GO号,而GO号可对于到Term,即功能类别或者细胞定位。根据挑选出的差异基因,计算这些差异基因同GO 分类中某(几)个特定的分支的超几何分布关系,..._r语言 go分析
文章浏览阅读1.8k次,点赞2次,收藏7次。 前几天因为博主的个人博客即将到期,因此特意从个人博客搬运出了文章:超详细教程】阿里云+宝塔+Typecho零基础搭建个人博客全套式教程——以免费领取的ECS阿里云服务器为例。然而,昨天因为在阿里云高校计划续费测试中拿到了90分成功续命了之前白嫖的阿里云服务器。因此在今天,博主就来为大家分享一下刚搭建好的音乐播放器的实现步骤与经验总结。目录前期准备实现步骤1.添加站点2.下载GitHub项目到本地3.部署音乐播_宝塔搭建一个音乐系统
文章浏览阅读217次。5.配有基于SpringBoot、Vue、uniapp、Qt的Web端、移动端、PC端,远程控制,远程查看数据。6.云平台具有设备管理、数据管理等完整的功能。4.远程设置光照强度和土壤湿度的阈值。2.湿度太干时自动打开水泵进行浇水。1.实时监测光照强度、土壤湿度。基于STM32的智慧灌溉系统。3.光照太暗时自动开灯补光。5.通信基于MQTT协议。
文章浏览阅读445次,点赞11次,收藏10次。开放实验室管理系统从功能、数据流程、可行性、运行环境进行需求分析。对开放实验室管理系统的数据库、功能进行了详细设计,分析了主要界面设计和相关组件设计,开放实验室管理系统的具体实现进行了介绍。从数据库中获取数据、向数据库中写入数据,实现系统直接对数据库进行各种数据库查询、插入、删除、更新等操作,在网页中加入动态内容,从而实现开放实验室管理系统所需要的各种基本功能。
文章浏览阅读2.5w次,点赞20次,收藏236次。文章目录_李亚普诺夫稳定性
文章浏览阅读1.4k次。目录基于MC34063芯片的DC-DC(20/5)降压型变换电路.................................................................21引言......................................................................................................_dc电源芯片 20a
文章浏览阅读128次。当从一个表中将记录Copy到另一个结构相同的表中的时候,有两种方式:DataTable.ImportRow()或: DataTable.Rows.Add()正确的使用方法: dt1.ImportRow(dt.Rows[0]);或: dt1.Rows.Add(dt.Rows[0].ItemArray);不要使用:..._add data row
文章浏览阅读1.5w次,点赞4次,收藏55次。文件表达式-e filename 如果 filename存在,则为真-d filename 如果 filename为目录,则为真-f filename 如果 filename为常规文件,则为真-L filename 如果 filename为符号链接,则为真-r filename 如果 filename可读,则为真-w filename 如果 filename可写,则为真-x filename 如果..._-f
文章浏览阅读301次。【代码】【JS】根据日期和给定的天数,计算日期的前几天或者后几天的日期时间。_js计算某个日期多少天后的日期