源碼網站開發(基於SpringBoot)

前言推薦這個項目是因為使用手冊部署手冊非常完善,項目也有開發教程視頻對小白非常貼心,接私活可以直接拿去二開非常舒服開源說明系統100%開源模塊化開發模式,銘飛所開發的模塊都發佈到瞭maven中央庫。可以通過pom.xml文件的方式拉取源代碼<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>模塊</artifactId>
<version>版本號</version>
<classifier>sources</classifier>
<scope>provided</scope>
</dependency>商用基於MIT開源協議,可直接商用無需授權,但請尊重開源精神不要去掉代碼中銘飛的註釋和版權信息特點免費完整開源:基於MIT協議,源代碼完全開源,無商業限制,MS開發團隊承諾將MCMS內容系統永久完整開源;關註Java項目分享標簽化建站:不需要專業的後臺開發技能,隻要使用系統提供的標簽,就能輕松建設網站;html靜態化:系統支持全站靜態化;跨終端:站點同時支持PC與移動端訪問,同時會自動根據訪問的終端切換到對應的界面,數據由系統統一管理;海量模版:銘飛通過MStore(MS商城)分享更多免費、精美的企業網站模版,降低建站成本;關註Java項目分享豐富插件:為瞭讓MCms適應更多的業務場景,在MStore用戶可以下載對應的插件,如:站群插件、微信插件、商城插件等;每月更新:銘飛團隊承諾每月28日為系統升級日,分享更多好用等模版與插件;文檔豐富:為瞭讓用戶更快速的使用MCms系統進行開發,銘飛團隊持續更新開發相關文檔,如標簽文檔、使用文檔、視頻教程等;面向對象企 業:幫助創立初期的公司或團隊快速搭建產品的技術平臺,加快公司項目開發進度;開發者:幫助開發者快速完成承接外包的項目,避免從零搭建系統;學習者:初學JAVA的同學可以下載源代碼來進行學習交流;開發環境建議開發者使用以下環境,這樣避免版本帶來的問題Windows、LinuxEclipse、IdeaMysql≧5.7JDK≧8Tomcat≧81. MCms內容插件手冊MCms內容插件提供最基本的菜單、權限、角色、欄目、內容、靜態化、等常用功能。視頻教程:內容插件視頻教程 配合代碼生成器使用快速提升開發效率:代碼生成器在線視頻教程、代碼生成器使用文檔1.1. Apache Maven依賴1.1.1. 當前版本<!– ms-mcms 內容模塊插件 –>
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>ms-mcms</artifactId>
<version>當前版本</version>
</dependency>
<!– ms-mcms 內容模塊源碼 –>
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>ms-mcms</artifactId>
<version>當前版本</version>
<classifier>sources</classifier>
</dependency>Copy1.2. 接口項目訪問路徑/swagger-ui.html#/系統部署手冊 1. jar部署1.1. 打包方式1懶人做法,將所有的資源打成一個jar包,維護資源不方便,不推薦mvn clean package
java -jar ms-mcms.jarCopy1.2. 打包方式2(推薦)打包指令增加參數 -f bin-xml ,執行完成會在target目錄會生成 “ 項目-bin ” 發佈文件夾mvn clean package -f bin-xml
Copy1.2.1. 目錄結構config:配置文件html:靜態化自動生成的目錄(自動生成)static:靜態資源文件templets:(必須)模版目錄,需要復制一份upload:(必須)上傳的文件夾WEB-INF:ftl視圖文件mcms.log:自動生成的日志文件*.sh:linux啟動、停止腳本*.bat:window啟動、停止腳本技術選型後端框架技術名稱官網Spring Framework容器http://projects.spring.io/spring-frameworkSpring BootMVC框架https://spring.io/projects/spring-bootApache Shiro安全框架http://shiro.apache.orgSpring session分佈式Session管理http://projects.spring.io/spring-sessionMyBatisORM框架http://www.mybatis.orgFreemarker視圖框架http://freemarker.foofun.cnPageHelperMyBatis分頁插件http://git.oschina.net/free/Mybatis_PageHelperLog4J日志組件http://logging.apache.orgMaven項目構建http://maven.apache.orgElasticsearch分佈式搜索引擎https://www.elastic.coRedis分佈式緩存數據庫https://redis.iohutool工具類http://hutool.mydoc.io前端框架技術名稱官網vue函式庫https://cn.vuejs.org//element uiUI庫https://element.eleme.cn/2.0/#/zh-CNjQuery函式庫http://jquery.com/Bootstrap前端框架http://getbootstrap.com/Bootstrap-tableBootstrap數據表格http://bootstrap-table.wenzhixin.net.cn/BootstrapValidator表單驗證http://bootstrapvalidator.com/Font-awesome字體圖標http://fontawesome.io/Waves點擊效果插件https://github.com/fians/Waves/zTree樹插件http://www.treejs.cn/v3/Select2選擇框插件https://github.com/select2/select2VueMVVM框架https://cn.vuejs.org/AmazeUI移動端UIhttp://amazeui.org/Plupload上傳控件http://www.plupload.com/freemarker模板引擎http://freemarker.foofun.cn/toc.htmlvalidator驗證庫https://github.com/chriso/validator.jsanimate動畫http://daneden.github.io/animate.css/icon矢量小圖標(待更新)http://ms.mingsoft.net/html/86//6048/index.html軟件截圖銘飛平臺做開源我們是業餘的,寫代碼我們是認真的。研發產品的路上我們一直在探索、一直在學習、一直在用心投入,希望能給更多的企業與開發者提供一些更有價值的服務。項目管理代碼生成器源碼資料獲取方式:關註小編+轉發文章+私信【 666 】免費獲取八股文面試資料獲取方式:關註小編+轉發文章+私信【 13 】免費獲取重要的事情說三遍,轉發+轉發+轉發,一定要記得點贊轉發哦!!!面試官:Spring 和 Spring Boot 的區別是什麼?概述對於 Spring和 SpringBoot到底有什麼區別,我聽到瞭很多答案,剛開始邁入學習 SpringBoot的我當時也是一頭霧水,隨著經驗的積累、我慢慢理解瞭這兩個框架到底有什麼區別,相信對於用瞭 SpringBoot很久的同學來說,還不是很理解 SpringBoot到底和 Spring有什麼區別,看完文章中的比較,或許你有瞭不同的答案和看法!什麼是Spring作為 Java開發人員,大傢都 Spring都不陌生,簡而言之, Spring框架為開發 Java應用程序提供瞭全面的基礎架構支持。它包含一些很好的功能,如依賴註入和開箱即用的模塊,如:SpringJDBC、SpringMVC、SpringSecurity、SpringAOP、SpringORM、SpringTest,這些模塊縮短應用程序的開發時間,提高瞭應用開發的效率例如,在 JavaWeb開發的早期階段,我們需要編寫大量的代碼來將記錄插入到數據庫中。但是通過使用 SpringJDBC模塊的 JDBCTemplate,我們可以將操作簡化為幾行代碼。什麼是Spring BootSpringBoot基本上是 Spring框架的擴展,它消除瞭設置 Spring應用程序所需的 XML配置,為更快,更高效的開發生態系統鋪平瞭道路。SpringBoot中的一些特征:1、創建獨立的 Spring應用。2、嵌入式 Tomcat、 Jetty、 Undertow容器(無需部署war文件)。3、提供的 starters 簡化構建配置4、盡可能自動配置 spring應用。5、提供生產指標,例如指標、健壯檢查和外部化配置6、完全沒有代碼生成和 XML配置要求從配置分析Maven依賴首先,讓我們看一下使用Spring創建Web應用程序所需的最小依賴項<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.1.0.RELEASE</version>
</dependency>與Spring不同,Spring Boot隻需要一個依賴項來啟動和運行Web應用程序:<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>在進行構建期間,所有其他依賴項將自動添加到項目中。另一個很好的例子就是測試庫。我們通常使用 SpringTest, JUnit, Hamcrest和 Mockito庫。在 Spring項目中,我們應該將所有這些庫添加為依賴項。但是在 SpringBoot中,我們隻需要添加 spring-boot-starter-test依賴項來自動包含這些庫。Spring Boot為不同的Spring模塊提供瞭許多依賴項。一些最常用的是:spring-boot-starter-data-jpaspring-boot-starter-securityspring-boot-starter-testspring-boot-starter-webspring-boot-starter-thymeleaf有關 starter的完整列表,請查看Spring文檔。MVC配置讓我們來看一下 Spring和 SpringBoot創建 JSPWeb應用程序所需的配置。Spring需要定義調度程序 servlet,映射和其他支持配置。我們可以使用 web.xml 文件或 Initializer類來完成此操作:public class MyWebAppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext container) {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setConfigLocation("com.pingfangushi");
container.addListener(new ContextLoaderListener(context));
ServletRegistration.Dynamic dispatcher = container
.addServlet("dispatcher", new DispatcherServlet(context));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
}還需要將 @EnableWebMvc註釋添加到 @Configuration類,並定義一個視圖解析器來解析從控制器返回的視圖:@EnableWebMvc
@Configuration
public class ClientWebConfig implements WebMvcConfigurer {
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver bean
= new InternalResourceViewResolver();
bean.setViewClass(JstlView.class);
bean.setPrefix("/WEB-INF/view/");
bean.setSuffix(".jsp");
return bean;
}
}再來看 SpringBoot一旦我們添加瞭 Web啟動程序, SpringBoot隻需要在 application配置文件中配置幾個屬性來完成如上操作:spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp上面的所有Spring配置都是通過一個名為auto-configuration的過程添加 Bootweb starter來自動包含的。這意味著 SpringBoot將查看應用程序中存在的依賴項,屬性和 bean,並根據這些依賴項,對屬性和 bean進行配置。當然,如果我們想要添加自己的自定義配置,那麼 SpringBoot自動配置將會退回。配置模板引擎現在我們來看下如何在Spring和Spring Boot中配置Thymeleaf模板引擎。在 Spring中,我們需要為視圖解析器添加 thymeleaf-spring5依賴項和一些配置:@Configuration
@EnableWebMvc
public class MvcWebConfig implements WebMvcConfigurer {
@Autowired
private ApplicationContext applicationContext;
@Bean
public SpringResourceTemplateResolver templateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(applicationContext);
templateResolver.setPrefix("/WEB-INF/views/");
templateResolver.setSuffix(".html");
return templateResolver;
}
@Bean
public SpringTemplateEngine templateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver());
templateEngine.setEnableSpringELCompiler(true);
return templateEngine;
}
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
resolver.setTemplateEngine(templateEngine());
registry.viewResolver(resolver);
}
}SpringBoot1X隻需要 spring-boot-starter-thymeleaf的依賴項來啟用 Web應用程序中的 Thymeleaf支持。   但是由於 Thymeleaf3.0中的新功能,我們必須將 thymeleaf-layout-dialect 添加為 SpringBoot2XWeb應用程序中的依賴項。配置好依賴,我們就可以將模板添加到 src/main/resources/templates文件夾中, SpringBoot將自動顯示它們。Spring Security 配置為簡單起見,我們使用框架默認的 HTTPBasic身份驗證。讓我們首先看一下使用 Spring啟用 Security所需的依賴關系和配置。Spring首先需要依賴 spring-security-web和 spring-security-config 模塊。接下來, 我們需要添加一個擴展 WebSecurityConfigurerAdapter的類,並使用 @EnableWebSecurity註解:@Configuration
@EnableWebSecurity
public class CustomWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("admin")
.password(passwordEncoder()
.encode("password"))
.authorities("ROLE_ADMIN");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest().authenticated()
.and()
.httpBasic();
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}這裡我們使用 inMemoryAuthentication來設置身份驗證。同樣, SpringBoot也需要這些依賴項才能使其工作。但是我們隻需要定義 spring-boot-starter-security的依賴關系,因為這會自動將所有相關的依賴項添加到類路徑中。SpringBoot中的安全配置與上面的相同 。應用程序啟動引導配置Spring和 SpringBoot中應用程序引導的基本區別在於 servlet。Spring使用 web.xml 或 SpringServletContainerInitializer作為其引導入口點。SpringBoot僅使用 Servlet3功能來引導應用程序,下面讓我們詳細來瞭解下Spring 引導配置Spring支持傳統的 web.xml引導方式以及最新的 Servlet3+方法。配置 web.xml方法啟動的步驟Servlet容器(服務器)讀取 web.xmlweb.xml中定義的 DispatcherServlet由容器實例化DispatcherServlet通過讀取 WEB-INF/{servletName}-servlet.xml來創建 WebApplicationContext。最後, DispatcherServlet註冊在應用程序上下文中定義的 bean使用 Servlet3+方法的 Spring啟動步驟容器搜索實現 ServletContainerInitializer的類並執行 SpringServletContainerInitializer找到實現所有類 WebApplicationInitializer“WebApplicationInitializer創建具有XML或上下文 @Configuration類 WebApplicationInitializer創建 DispatcherServlet與先前創建的上下文。SpringBoot 引導配置Spring Boot應用程序的入口點是使用@SpringBootApplication註釋的類@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}默認情況下, SpringBoot使用嵌入式容器來運行應用程序。在這種情況下, SpringBoot使用 publicstaticvoidmain入口點來啟動嵌入式 Web服務器。此外,它還負責將 Servlet, Filter和 ServletContextInitializerbean從應用程序上下文綁定到嵌入式 servlet容器。SpringBoot的另一個特性是它會自動掃描同一個包中的所有類或 Main類的子包中的組件。SpringBoot提供瞭將其部署到外部容器的方式。我們隻需要擴展 SpringBootServletInitializer即可:/**
* War部署
*
* @author SanLi
* Created by [email protected] on 2018/4/15
*/
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
servletContext.addListener(new HttpSessionEventPublisher());
}
}這裡外部 servlet容器查找在war包下的 META-INF文件夾下MANIFEST.MF文件中定義的 Main-class, SpringBootServletInitializer將負責綁定 Servlet, Filter和 ServletContextInitializer。打包和部署最後,讓我們看看如何打包和部署應用程序。這兩個框架都支持 Maven和 Gradle等通用包管理技術。但是在部署方面,這些框架差異很大。例如,Spring Boot Maven插件在 Maven中提供 SpringBoot支持。它還允許打包可執行 jar或 war包並 就地運行應用程序。在部署環境中 SpringBoot 對比 Spring的一些優點包括:1、提供嵌入式容器支持2、使用命令java -jar獨立運行jar3、在外部容器中部署時,可以選擇排除依賴關系以避免潛在的jar沖突4、部署時靈活指定配置文件的選項5、用於集成測試的隨機端口生成結論簡而言之,我們可以說 SpringBoot隻是 Spring本身的擴展,使開發,測試和部署更加方便。

本文出自快速备案,转载时请注明出处及相应链接。

本文永久链接: https://kuaisubeian.cc/48838.html

kuaisubeian