說明:因爲單體項目將全部的模塊都寫到了一塊兒,未來若是其中一個模塊出了問題,將致使整個項目不能正常的運行!
java
因爲傳統項目致使各個模塊之間的耦合性較高,因此須要採用分佈式的思想將項目進行拆分。
核心理念:化整爲零 將項目按照某些特定的規則進行拆分!mysql
說明:因爲單體項目的耦合性較高,全部須要按照功能模塊進行拆分【下降系統架構的耦合性】web
在按照模塊拆分的基礎之上,將項目按照層級拆分,將粒度控制的更加的具體。分工更加的明確,有效的提升軟件的開發效率!redis
<?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"> <modelVersion>4.0.0</modelVersion> <groupId>com.jt</groupId> <artifactId>jt</artifactId> <version>1.0-SNAPSHOT</version> <!--modules表示當前的項目包含了多少個子級項目, 一個modules就是一個子級項目。 注意:若是修改了項目的名稱記得必定要修改modules標籤裏面的名稱--> <modules> <module>jt-common</module> <module>jt-manage</module> </modules> <!--父級工程的打包類型--> <packaging>pom</packaging> <!--引入springboot的jar文件 springboot父級項目--> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.4.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <!--2.引入屬性的配置--> <properties> <java.version>1.8</java.version> <!--跳過測試類打包--> <skipTests>true</skipTests> </properties> <!--3.在父級項目中添加jar包文件--> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <!--springBoot數據庫鏈接 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <!--spring整合mybatis-plus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.2.0</version> </dependency> <!--springBoot整合JSP添加依賴 --> <!--servlet依賴 --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> </dependency> <!--jstl依賴 --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> <!--使jsp頁面生效 --> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> </dependency> <!--支持熱部署--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency> <!--添加httpClient jar包 --> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> </dependency> <!--引入dubbo配置 --> <!--<dependency> <groupId>com.alibaba.boot</groupId> <artifactId>dubbo-spring-boot-starter</artifactId> <version>0.2.0</version> </dependency>--> <!--添加Quartz的支持 --> <!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-quartz</artifactId> </dependency>--> <!--spring整合redis --> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> </dependency> <!-- 引入aop支持 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> </dependencies> <!--父級工程只是項目的管理者,不會在其中編輯代碼,因此不要添加build--> </project>
<?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"> <modelVersion>4.0.0</modelVersion> <artifactId>jt-manage</artifactId> <!--指定打包方式--> <packaging>war</packaging> <!--指定父級項目--> <parent> <artifactId>jt</artifactId> <groupId>com.jt</groupId> <version>1.0-SNAPSHOT</version> </parent> <!--2.添加依賴信息--> <dependencies> <dependency> <groupId>com.jt</groupId> <artifactId>jt-common</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> <!--3.添加插件--> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
步驟:
1.http://localhost:8091/
2.默認機制:http://localhost:8091/index請求...被springBoot程序優化過了。
3.利用默認工具API
WelcomePageHandlerMapping : Adding welcome page template: index動態的發起的/index請求,以後配合視圖解析器造成動態的頁面路徑:/WEB-INF/views/index.jspspring
注意事項:
當使用SpringBoot程序時,能夠經過缺省值訪問,可是系統的首頁名稱必須爲index.xxxxsql