当前位置: 首页 > news >正文

做网站会用到什么语言营销型网站建设明细报

做网站会用到什么语言,营销型网站建设明细报,论坛怎样发帖推广,wordpress网站的优化Spring安全性是一个很棒的框架#xff0c;可节省开发人员的大量时间和精力。 此外#xff0c;它还具有足够的灵活性#xff0c;可以自定义并满足您的需求。 使用JDBC和Spring Security非常容易#xff0c;并且许多操作是自动化的。 这将是一个最小的展示。 gradle文件包含… Spring安全性是一个很棒的框架可节省开发人员的大量时间和精力。 此外它还具有足够的灵活性可以自定义并满足您的需求。 使用JDBC和Spring Security非常容易并且许多操作是自动化的。 这将是一个最小的展示。 gradle文件包含诸如spring-securityspring-jdbc和h2数据库之类的依赖项 group com.gkatzioura version 1.0-SNAPSHOTbuildscript {repositories {mavenCentral()}dependencies {classpath(org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE)} }apply plugin: java apply plugin: idea apply plugin: spring-bootsourceCompatibility 1.8repositories {mavenCentral() }dependencies {compile(org.springframework.boot:spring-boot-starter-web)compile(org.thymeleaf:thymeleaf-spring4)compile(org.springframework.boot:spring-boot-starter-security)compile(org.springframework:spring-jdbc)compile(com.h2database:h2:1.4.192)compile(org.slf4j:slf4j-api:1.6.6)compile(ch.qos.logback:logback-core:1.1.7)compile(ch.qos.logback:logback-classic:1.1.7)testCompile junit:junit:4.11 } 必须创建包含某些信息的表。 这些表将具有Spring安全性查询的默认名称和列名称以获取信息。 drop table if exists users; create table users(id bigint auto_increment, username varchar(255), password varchar(255), enabled boolean); insert into users(username,password,enabled) values(steve,steve,true); insert into users(username,password,enabled) values(john,john,true); drop table if exists authorities; create table authorities(username varchar(255),authority varchar(255), UNIQUE(username,authority)); insert into authorities(username,authority) values(steve,admin); insert into authorities(username,authority) values(john,superadmin); 这些sql语句将驻留在resources / schema.sql上。 第一步是创建我们的Application类 package com.gkatzioura.spring.security;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;/*** Created by gkatzioura on 9/2/16.*/ SpringBootApplication public class Application {public static void main(String[] args) {SpringApplication.run(Application.class, args);}} 为了快速入门该数据库将为h2数据库。 package com.gkatzioura.spring.security.config;import org.h2.jdbcx.JdbcDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;import javax.sql.DataSource; import java.nio.file.Files;/*** Created by gkatzioura on 9/2/16.*/ Configuration public class DataSourceConfig {Beanpublic DataSource createDataSource() {JdbcDataSource dataSource new JdbcDataSource();dataSource.setURL(jdbc:h2:System.getProperty(java.io.tmpdir)/database);return dataSource;}} 通过指定h2数据库我将该目录设置为临时目录内。 因此一旦重新启动操作系统数据库将消失。 如前所述以前一旦数据源豆已初始化弹簧JDBC会自动查找上一个schema.sql文件的文件资源文件夹。 如果文件存在spring-jdbc将尝试执行schema.sql包含的语句。 下一步是定义我们的安全配置。 我们必须指定我们的安全性将基于jdbc。 同样我们必须定义必须安全的端点。 package com.gkatzioura.spring.security.config;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;import javax.sql.DataSource;/*** Created by gkatzioura on 9/2/16.*/ EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter {Autowiredprivate DataSource dataSource;Autowiredpublic void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {auth.jdbcAuthentication().dataSource(dataSource);}Overrideprotected void configure(HttpSecurity http) throws Exception {http.authorizeRequests().antMatchers(/public).permitAll().anyRequest().authenticated().and().formLogin().permitAll().and().logout().permitAll();} } 最后但并非最不重要的一点是我们将添加具有安全端点和非安全端点的控制器 package com.gkatzioura.spring.security.controller;import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController;/*** Created by gkatzioura on 9/2/16.*/ RestController public class GreetController {private static final Logger LOGGER LoggerFactory.getLogger(GreetController.class);RequestMapping(path /public,method RequestMethod.GET)public String sayFreeHi() {return Greeting;}RequestMapping(path /secured,method RequestMethod.GET)public String saySecureHi() {return Secured;}} 一旦尝试访问安全端点将显示默认的spring security登录屏幕。 继续执行sql语句中指定的用户之一例如用户名steve密码steve。 如果您要注销只需点击/ loginlogout端点即可。 运行带有 gradle bootRun 而且你很好。 您可以在github上找到源代码 翻译自: https://www.javacodegeeks.com/2016/09/spring-boot-spring-security-jdbc.html
http://wiki.neutronadmin.com/news/12439/

相关文章:

  • 建设银行租房网站首页天津手机版建站系统哪个好
  • 最好的网站开发wordpress js无效
  • 东莞++网站建设企业名称登记管理实施办法
  • 青岛营销型网站四川seo推广
  • 网站建设xml下载游戏网站建设的目的
  • 求网站备案照片商城系统网站模板免费下载
  • 政务服务 网站 建设方案做网站1000以下哪家好
  • 广元网站建设seo优化营销制作设计设置wordpress文章图片不显示
  • 洛阳西工区做网站哪家好微信公众号内置手机网站
  • 建设网站第一步宁远做网站
  • 做网站商城需要什么软件博客网站建设设计报告
  • 网站制作属于什么专业门户网站兴化建设局 金
  • 网站开发语言为 php帮朋友免费做网站
  • 湖北皇奥建设工程有限公司网站新浪微博网页版
  • 企业网站建设需要考虑内容爱站网新网址是多少
  • 济南外贸网站制作深圳广告设计公司网站
  • 网站建设落地页北京住建个人证书查询网
  • 营销型网站跟云网站阿里巴巴国际站做2个网站有用
  • 青岛网站建设团队电脑优化软件推荐
  • 广州网站建设比较好的公司在哪可以找到做网站的
  • 网站建设与优化推广方案手机做任务网站
  • 中国建设劳动协会网站定制型网站建设平台
  • php网站开发图文教程小程序登录跳转
  • php做网站最容易网站没被收录怎么办
  • 深圳上市公司全部名单杭州seo网站
  • 哪些网站论坛做推广好河南网站建设yipinpai
  • 网站建设方案书生鲜重庆建设传动科技有限公司
  • 哈尔滨手机网站建设价格邢台seo技术
  • 科技风格设计网站中山做网站公司
  • qingdao城乡住房建设厅网站大连模板网站制作电话