成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

jeecg-boot中怎么新建一個(gè)module模塊

這篇文章給大家介紹jeecg-boot中怎么新建一個(gè)module模塊,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

成都創(chuàng)新互聯(lián)一直通過(guò)網(wǎng)站建設(shè)和網(wǎng)站營(yíng)銷幫助企業(yè)獲得更多客戶資源。 以"深度挖掘,量身打造,注重實(shí)效"的一站式服務(wù),以成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、移動(dòng)互聯(lián)產(chǎn)品、成都全網(wǎng)營(yíng)銷推廣服務(wù)為核心業(yè)務(wù)。10余年網(wǎng)站制作的經(jīng)驗(yàn),使用新網(wǎng)站建設(shè)技術(shù),全新開發(fā)出的標(biāo)準(zhǔn)網(wǎng)站,不但價(jià)格便宜而且實(shí)用、靈活,特別適合中小公司網(wǎng)站制作。網(wǎng)站管理系統(tǒng)簡(jiǎn)單易用,維護(hù)方便,您可以完全操作網(wǎng)站資料,是中小公司快速網(wǎng)站建設(shè)的選擇。

jeecg-boot新建module模塊

新建maven項(xiàng)目

新建maven項(xiàng)目 取名jeecg-boot-module-jm

可以采用idea、myeclipse 等工具來(lái)新建一個(gè)maven項(xiàng)目

其中 pom.xml文件內(nèi)容如下

<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>jeecg-boot-module-jm</artifactId>
	<version>2.0.2</version>

	<parent>
		<groupId>org.jeecgframework.boot</groupId>
		<artifactId>jeecg-boot-parent</artifactId>
		<version>2.0.2</version>
	</parent>

	<repositories>
		<repository>
			<id>aliyun</id>
			<name>aliyun Repository</name>
			<url>http://maven.aliyun.com/nexus/content/groups/public</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
		<repository>
			<id>jeecg</id>
			<name>jeecg Repository</name>
			<url>http://maven.jeecg.org/nexus/content/repositories/jeecg</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
	</repositories>
	
	<dependencies>
		<dependency>
			<groupId>org.jeecgframework.boot</groupId>
			<artifactId>jeecg-boot-base-common</artifactId>
		</dependency>
	</dependencies>
	
	<!-- <build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build> -->
</project>

注意:我這個(gè)pom文件直接復(fù)制了jeecg-boot-module-system 內(nèi)容,將jeecg-boot-module-system名稱改為jeecg-boot-module-jm,注意注釋了

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

這段代碼,因?yàn)樾陆ǖ捻?xiàng)目要打包為jar在jeecg-boot-module-system引用,所以不需要把該項(xiàng)目打包一個(gè)springboot項(xiàng)目,注釋上面的代碼就可以了。

  • 創(chuàng)建業(yè)務(wù)包

在項(xiàng)目根目錄新建包名org.jeecg.modules.hello(以issues:373為例,也可以使用其他包名,記住這個(gè)包名,后面在接口問(wèn)題swagger-ui使用到)

  • 添加業(yè)務(wù)(測(cè)試)代碼

(以issues:373為例,后面針對(duì)提出的問(wèn)題,進(jìn)行一一解答)這段代碼后面在swagegr-ui中訪問(wèn)不到,因?yàn)榉椒ㄉ蠜]有添加@ApiOperation

package org.jeecg.modules.hello;

import org.jeecg.common.api.vo.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;

/**
 * 測(cè)試新的module
 * @author chengtg
 *
 */
@Slf4j
@Api(tags="新建module--jm")
@RestController
@RequestMapping("/hello")
public class HelloController  {
	@GetMapping(value="/")
	public Result<String> hello(){
		Result<String> result = new Result<String>();
		result.setResult("hello word!");
		result.setSuccess(true);
		return result;
	}
}

注意:我修改了注釋(@Api(tags="新建module--jm")),后面在swagegr-ui文檔用到

  • 將新建的項(xiàng)目納入parent中

將新建的jeecg-boot-module-jm 納入jeecg-boot-parent中

在jeecg-boot-framework項(xiàng)目中的pom文件 modules中添加<module>jeecg-boot-module-jm</module>

結(jié)果如下代碼

	<modules>
		<module>jeecg-boot-base-common</module>
		<module>jeecg-boot-module-system</module>
		<module>jeecg-boot-module-jm</module>
	</modules>

添加項(xiàng)目依賴

在jeecg-boot-module-system項(xiàng)目中依賴 jeecg-boot-module-jms

修改jeecg-boot-module-system項(xiàng)目的pom文件

<dependencies>
		<dependency>
			<groupId>org.jeecgframework.boot</groupId>
			<artifactId>jeecg-boot-base-common</artifactId>
		</dependency>
		<dependency>
			<groupId>org.jeecgframework.boot</groupId>
			<artifactId>jeecg-boot-module-jm</artifactId>
			<version>2.0.2</version>
		</dependency>
</dependencies>

編譯整個(gè)jeecg-boot-framework

如果編譯如下:

[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ jeecg-boot-module-system ---
[INFO] Installing /Users/chengtg/WS-platform/jeecg-boot-framework/jeecg-boot-module-system/target/jeecg-boot-module-system-2.0.2.jar to /Users/chengtg/.m2/repository/org/jeecgframework/boot/jeecg-boot-module-system/2.0.2/jeecg-boot-module-system-2.0.2.jar
[INFO] Installing /Users/chengtg/WS-platform/jeecg-boot-framework/jeecg-boot-module-system/pom.xml to /Users/chengtg/.m2/repository/org/jeecgframework/boot/jeecg-boot-module-system/2.0.2/jeecg-boot-module-system-2.0.2.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for jeecg-boot-parent 2.0.2:
[INFO] 
[INFO] jeecg-boot-parent .................................. SUCCESS [  0.236 s]
[INFO] jeecg-boot-base-common ............................. SUCCESS [  1.143 s]
[INFO] jeecg-boot-module-jm ............................... SUCCESS [  1.066 s]
[INFO] jeecg-boot-module-system ........................... SUCCESS [  3.125 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.872 s
[INFO] Finished at: 2019-08-04T21:41:09+08:00
[INFO] ------------------------------------------------------------------------

說(shuō)明,新建項(xiàng)目jeecg-boot-module-jm并在jeecg-boot-module-system中依賴,成功!

  • 啟動(dòng)jeecg-boot-module-system項(xiàng)目

  • 訪問(wèn)接口文檔swagger

http://localhost:8080/jeecg-boot/doc.html

截圖如下:

  • jeecg-boot中怎么新建一個(gè)module模塊

問(wèn)題來(lái)了:為什么新添加的HelloController中@Api(tags="新建module--jm")沒有 顯示

原因查看Swagger2Config配置,Swagger2Config.java

因?yàn)榻貓D中紅色圈出來(lái)的 部分

//加了ApiOperation注解的類,才生成接口文檔
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))

表示只有在controller類的方法上要添加ApiOperation注解的,否則是不生成swagegr-ui文檔

  • 修改HelloController代碼

修改jeecg-boot-module-system-jm項(xiàng)目HelloController類,給hello方法添加ApiOperation注解

package org.jeecg.modules.hello;

import org.jeecg.common.api.vo.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;

/**
 * 測(cè)試新的module
 * @author chengtg
 *
 */
@Slf4j
@Api(tags="新建module--jm")
@RestController
@RequestMapping("/hello")
public class HelloController  {
	@ApiOperation("測(cè)試hello方法")
	@GetMapping(value="/")
	public Result<String> hello(){
		Result<String> result = new Result<String>();
		result.setResult("hello word!");
		result.setSuccess(true);
		return result;
	}
}

重新編譯啟動(dòng)。

再次訪問(wèn)接口文檔swagger:http://localhost:8080/jeecg-boot/doc.html

  • 奇跡出現(xiàn)了

jeecg-boot中怎么新建一個(gè)module模塊

  • 測(cè)試接口-調(diào)試

jeecg-boot中怎么新建一個(gè)module模塊

代碼如下:

package org.jeecg.config;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.servlet.Filter;

import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
import org.apache.shiro.mgt.DefaultSubjectDAO;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.jeecg.modules.shiro.authc.ShiroRealm;
import org.jeecg.modules.shiro.authc.aop.JwtFilter;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

/**
 * @author: Scott
 * @date: 2018/2/7
 * @description: shiro 配置類
 */

@Configuration
public class ShiroConfig {
	
	/**
	 * Filter Chain定義說(shuō)明 
	 * 
	 * 1、一個(gè)URL可以配置多個(gè)Filter,使用逗號(hào)分隔
	 * 2、當(dāng)設(shè)置多個(gè)過(guò)濾器時(shí),全部驗(yàn)證通過(guò),才視為通過(guò)
	 * 3、部分過(guò)濾器可指定參數(shù),如perms,roles
	 */
	@Bean("shiroFilter")
	public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) {
		ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
		shiroFilterFactoryBean.setSecurityManager(securityManager);
		// 攔截器
		Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
		// 配置不會(huì)被攔截的鏈接 順序判斷
		filterChainDefinitionMap.put("/hello/**", "anon"); //測(cè)試新添加的module,不帶token訪問(wèn)
		filterChainDefinitionMap.put("/sys/login", "anon"); //登錄接口排除
		filterChainDefinitionMap.put("/sys/getEncryptedString", "anon"); //獲取加密串
		filterChainDefinitionMap.put("/sys/sms", "anon");//短信驗(yàn)證碼
		filterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手機(jī)登錄		
		filterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");//校驗(yàn)用戶是否存在
		filterChainDefinitionMap.put("/sys/user/register", "anon");//用戶注冊(cè)
		filterChainDefinitionMap.put("/sys/user/querySysUser", "anon");//根據(jù)手機(jī)號(hào)獲取用戶信息
		filterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");//用戶忘記密碼驗(yàn)證手機(jī)號(hào)
		filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用戶更改密碼
		filterChainDefinitionMap.put("/auth/2step-code", "anon");//登錄驗(yàn)證碼
		filterChainDefinitionMap.put("/sys/common/view/**", "anon");//圖片預(yù)覽不限制token
		filterChainDefinitionMap.put("/sys/common/download/**", "anon");//文件下載不限制token
		filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf預(yù)覽
		filterChainDefinitionMap.put("/generic/**", "anon");//pdf預(yù)覽需要文件
		filterChainDefinitionMap.put("/", "anon");
		filterChainDefinitionMap.put("/doc.html", "anon");
		filterChainDefinitionMap.put("/**/*.js", "anon");
		filterChainDefinitionMap.put("/**/*.css", "anon");
		filterChainDefinitionMap.put("/**/*.html", "anon");
		filterChainDefinitionMap.put("/**/*.svg", "anon");
		filterChainDefinitionMap.put("/**/*.jpg", "anon");
		filterChainDefinitionMap.put("/**/*.png", "anon");
		filterChainDefinitionMap.put("/**/*.ico", "anon");
		filterChainDefinitionMap.put("/druid/**", "anon");
		filterChainDefinitionMap.put("/swagger-ui.html", "anon");
		filterChainDefinitionMap.put("/swagger**/**", "anon");
		filterChainDefinitionMap.put("/webjars/**", "anon");
		filterChainDefinitionMap.put("/v2/**", "anon");
		
		//性能監(jiān)控
		filterChainDefinitionMap.put("/actuator/metrics/**", "anon");
		filterChainDefinitionMap.put("/actuator/httptrace/**", "anon");
		filterChainDefinitionMap.put("/actuator/redis/**", "anon");
		
		//表單設(shè)計(jì)器
		filterChainDefinitionMap.put("/desform/**", "anon"); //自定義表單
		filterChainDefinitionMap.put("/test/jeecgDemo/demo3", "anon"); //模板測(cè)試
		filterChainDefinitionMap.put("/test/jeecgDemo/redisDemo/**", "anon"); //redis測(cè)試
		

		//流程模塊組件請(qǐng)求
		filterChainDefinitionMap.put("/act/process/**", "anon");
		filterChainDefinitionMap.put("/act/task/**", "anon");
		filterChainDefinitionMap.put("/act/model/**", "anon");
		filterChainDefinitionMap.put("/service/editor/**", "anon");
		filterChainDefinitionMap.put("/service/model/**", "anon");
		filterChainDefinitionMap.put("/service/model/**/save", "anon");
		filterChainDefinitionMap.put("/editor-app/**", "anon");
		filterChainDefinitionMap.put("/diagram-viewer/**", "anon");
		filterChainDefinitionMap.put("/modeler.html", "anon");
		filterChainDefinitionMap.put("/designer", "anon");
		filterChainDefinitionMap.put("/designer/**", "anon");
		filterChainDefinitionMap.put("/plug-in/**", "anon");
	
		//排除Online請(qǐng)求
		filterChainDefinitionMap.put("/auto/cgform/**", "anon");
		//FineReport報(bào)表
		filterChainDefinitionMap.put("/ReportServer**", "anon");
	
		// 添加自己的過(guò)濾器并且取名為jwt
		Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
		filterMap.put("jwt", new JwtFilter());
		shiroFilterFactoryBean.setFilters(filterMap);
		// <!-- 過(guò)濾鏈定義,從上向下順序執(zhí)行,一般將/**放在最為下邊
		filterChainDefinitionMap.put("/**", "jwt");

		// 未授權(quán)界面返回JSON
		shiroFilterFactoryBean.setUnauthorizedUrl("/sys/common/403");
		shiroFilterFactoryBean.setLoginUrl("/sys/common/403");
		shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
		return shiroFilterFactoryBean;
	}

	@Bean("securityManager")
	public DefaultWebSecurityManager securityManager(ShiroRealm myRealm) {
		DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
		securityManager.setRealm(myRealm);

		/*
		 * 關(guān)閉shiro自帶的session,詳情見文檔
		 * http://shiro.apache.org/session-management.html#SessionManagement-
		 * StatelessApplications%28Sessionless%29
		 */
		DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
		DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
		defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
		subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
		securityManager.setSubjectDAO(subjectDAO);

		return securityManager;
	}

	/**
	 * 下面的代碼是添加注解支持
	 * @return
	 */
	@Bean
	@DependsOn("lifecycleBeanPostProcessor")
	public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
		DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
		defaultAdvisorAutoProxyCreator.setProxyTargetClass(true);
		return defaultAdvisorAutoProxyCreator;
	}

	@Bean
	public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
		return new LifecycleBeanPostProcessor();
	}

	@Bean
	public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultWebSecurityManager securityManager) {
		AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
		advisor.setSecurityManager(securityManager);
		return advisor;
	}

}

編譯并重啟服務(wù),

再次訪問(wèn)接口文檔http://localhost:8080/jeecg-boot/doc.html

jeecg-boot中怎么新建一個(gè)module模塊

關(guān)于jeecg-boot中怎么新建一個(gè)module模塊就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

分享文章:jeecg-boot中怎么新建一個(gè)module模塊
文章網(wǎng)址:http://jinyejixie.com/article26/ggepcg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司、自適應(yīng)網(wǎng)站、網(wǎng)站營(yíng)銷、用戶體驗(yàn)、關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)
衢州市| 麟游县| 延吉市| 兴化市| 武功县| 孟州市| 平谷区| 南部县| 湖北省| 香河县| 江津市| 小金县| 遵化市| 通州市| 西平县| 天峻县| 土默特右旗| 申扎县| 科尔| 南城县| 寿宁县| 镇安县| 家居| 舒兰市| 阳谷县| 丰顺县| 镇赉县| 房山区| 加查县| 乌兰县| 湄潭县| 会泽县| 金湖县| 无极县| 崇左市| 界首市| 墨玉县| 丹江口市| 淮北市| 达孜县| 满城县|