架构:第四章:微服务架构下的分布式架构之搭建环境

文章介绍了如何在SpringBoot项目中集成Eureka服务注册与发现,以及各个子工程的依赖管理和配置管理,包括mybatis、Druid数据源和Feign客户端的使用。此外,还提及了Java工程师自学资源的分享和面试准备的相关内容。
摘要由CSDN通过智能技术生成

org.activiti

activiti-spring-boot-starter-basic

在ProviderDatabase子工程的pom.xml中创建依赖管理和构建管理

4.0.0

com

CrowdFundingParent

0.0.1-SNAPSHOT

ProviderDatabase

mysql

mysql-connector-java

com.alibaba

druid

org.mybatis.spring.boot

mybatis-spring-boot-starter

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-test

test

org.springframework.cloud

spring-cloud-starter-eureka

org.springframework.cloud

spring-cloud-starter-config

com

CommonBean

0.0.1-SNAPSHOT

com

CommonFeign

0.0.1-SNAPSHOT

com

CommonUtil

0.0.1-SNAPSHOT

在RegisterCenterEureka子工程的pom.xml中创建依赖管理和构建管理

4.0.0

com

CrowdFundingParent

0.0.1-SNAPSHOT

RegisterCenterEureka

org.springframework.cloud

spring-cloud-starter-eureka-server

在CommonFeign子工程的pom.xml中创建依赖管理和构建管理

4.0.0

com

CrowdFundingParent

0.0.1-SNAPSHOT

CommonFeign

org.springframework.cloud

spring-cloud-starter-feign

com

CommonBean

0.0.1-SNAPSHOT

其他工程无依赖管理和构建管理,后期如果需要在加即可

创建各工程主启动类

RegisterCenterEureka

@EnableEurekaServer

@SpringBootApplication

ProviderDatabase

@EnableEurekaClient

@MapperScan(“com.mapper”)

@SpringBootApplication

ProviderActiviti

@EnableEurekaClient

@EnableFeignClients

@SpringBootApplication

ConsumerPortal

@EnableEurekaClient

@EnableFeignClients

@SpringBootApplication

ConsumerManager

@EnableEurekaClient

@EnableFeignClients

@SpringBootApplication

例图:

创建各工程yml文件

RegisterCenterEureka

server:

port: 84

eureka:

instance:

hostname: localhost

client:

register-with-eureka: false

fetch-registry: false

service-url:

defaultZone: http://localhost:84/eureka

ProviderDatabase

server:

port: 83

mybatis:

config-location: classpath:mybatis/mybatis.cfg.xml

mapper-locations:

  • classpath:mybatis/mapper/*Mapper.xml

spring:

application:

name: ProviderDatabase

datasource:

type: com.alibaba.druid.pool.DruidDataSource

driver-class-name: org.gjt.mm.mysql.Driver

url: jdbc:mysql://localhost:3306/atcrowdfunding?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf8

username: root

password: root

dbcp2:

min-idle: 5

initial-size: 5

max-total: 5

max-wait-millis: 200

eureka:

client:

service-url:

defaultZone: http://localhost:84/eureka

创建mybatis目录

创建mybatis.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>

ProviderActiviti

server:

port: 82

spring:

application:

name: ProviderActiviti

datasource:

type: com.alibaba.druid.pool.DruidDataSource

driver-class-name: org.gjt.mm.mysql.Driver

url: jdbc:mysql://localhost:3306/atcrowdfunding?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf8

username: root

password: root

dbcp2:

min-idle: 5

initial-size: 5

max-total: 5

max-wait-millis: 200

eureka:

client:

service-url:

defaultZone: http://localhost:84/eureka

ConsumerPortal

server:

port: 80

eureka:

client:

register-with-eureka: false

service-url:

defaultZone: http://localhost:84/eureka

spring:

freemarker:

template-loader-path: classpath:/templates/

suffix: .page

crowdfunding.tracker.config.location: classpath:/tracker.conf

创建templates目录

创建tracker.conf

tracker_server=192.168.0.100:22122

ConsumerManager

server:

port: 81

eureka:

client:

register-with-eureka: false

service-url:

defaultZone: http://localhost:84/eureka

spring:

freemarker:

template-loader-path: classpath:/templates/

suffix: .page

创建templates目录

现在写一个首页显示功能测试一下

显示首页:使用Freemarker作为SpringBoot环境下的视图技术,创建一个index.page,将前端页面摸板的index.html复制j进去

修改页面

修改后

在路径前加/表示在类路径下

修改后

添加静态资源

将下面的复制

在类路径下创建static文件夹,存放静态资源的文件目录必须是static

创建ProtalHandler.java

@Controller

public class PortalHandler {

@RequestMapping(“/main”)

public String toIndexPage() {

return “index”;

}

}

小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级Java工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Java开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频

如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Java)
img

总结

这个月马上就又要过去了,还在找工作的小伙伴要做好准备了,小编整理了大厂java程序员面试涉及到的绝大部分面试题及答案,希望能帮助到大家

在这里插入图片描述

在这里插入图片描述

xPage() {

return “index”;

}

}

小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级Java工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Java开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
[外链图片转存中…(img-nExH8pd7-1710425794675)]
[外链图片转存中…(img-CLDNUb3l-1710425794676)]
[外链图片转存中…(img-1g8hOy4z-1710425794676)]

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频

如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Java)
[外链图片转存中…(img-6HzHBz0Z-1710425794677)]

总结

这个月马上就又要过去了,还在找工作的小伙伴要做好准备了,小编整理了大厂java程序员面试涉及到的绝大部分面试题及答案,希望能帮助到大家

[外链图片转存中…(img-44fjbwt4-1710425794678)]

[外链图片转存中…(img-Lk4FznOz-1710425794678)]

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值