Spring Boot入门(连接MySQL, Redis 输出JSP)

SpringBoot(看这一篇就够了) Spring是一个非常优秀的轻量级框架,以IOC(控制反转)和AOP(面向切面)为思想内核,极大简化了JAVA企业级项目的开发。虽然Spring的组件代码是轻量级的,但它的配置却是重量级的。使用Spring进行项目开发需要在配置文件中写很多代码,所有这些配置都代表了开发时的损耗。除此之外,Spring项目的依赖管理也是一件耗时耗力的事情。在环境搭建时,需要分析要导入哪些库的坐标,而且还需要分析导入与之有依赖关系的其他库的坐标,一旦选错了依赖的版本,随之而来的不兼容问题就会严重阻碍项目的开发进度。比如Spri 阅读详情

本文主要介绍一下如何搭建一个基本的Spring-Boot项目,Spring-Boot也是Spring众多项目中的一个,主要用于快速的搭建项目。通常构建一个java web的maven项目,需要引入不少jar包,写不少xml配置(如果用注解就当我没说),有了Spring-Boot这些繁琐的事情可以简化很多,构建项目的效率可以大大提升,另外它内置web容器,你可以不要tomcat就运行一个web项目。

可以Google一下Spring-Boot了解更详细的信息,或者通过下面这个项目了解一下它的简便。本人使用Spring-Boot时间也不长,感触不多。

通过一个简单的查询数据库信息并展示的项目来感受一下:

1. 新建maven项目

2. pom.xml如下:

Spring-Boot的maven依赖包含了很多常用的jar,比如spring相关的,log相关的,所以第一次下来这些依赖的时候会比较久。

<?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.francis</groupId>
    <artifactId>springboot-framework</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

<!--官方推荐配置这个parent,主要是parent包含了很多jar,这样一来就不用自己写很多。-->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.0.RELEASE</version>
    </parent>



    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!--DB -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <!--Redis-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
        </dependency>

        <!--JSP-->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- apache common -->
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.3</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.0.1</version>
        </dependency>

        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3.1</version>
        </dependency>
    </dependencies>

    <properties>
        <java.version>1.8</java.version>
        <main.basedir>${basedir}/../..</main.basedir>
        <m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>-Dfile.encoding=UTF-8</argLine>
                    <useSystemClassLoader>false</useSystemClassLoader>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>

3. application.yml

这个是Spring-Boot的配置文件,可以配置很多项,具体的需要查看官方文档。

该文件放置在resources目录下(似乎只要是在classpath下面都行,通常是在resources下面)。

下面给出的这些是配置mysql连接和redis连接所需要的,根据文件中的配置和依赖的jar,Spring-Boot会自动创建DataSource对象,而你需要做的只是在配置文件中写清楚并引入相应的jar。(是不是很方便?)

spring:
#配置数据源
  datasource:
    url: jdbc:mysql://localhost:3306/test
    username: root
    password: abc123_
    driverClassName: com.mysql.jdbc.Driver
    max-wait: 10000
    max-active: 50
    test-on-borrow: false
#配置持久层框架
  jpa:
    database: MYSQL
    show-sql: true
    hibernate:
      ddl-auto: update
      dialect: org.hibernate.dialect.MySQL5Dialect
#SpringMVC视图解析配置
  mvc:
      view:
        prefix: /WEB-INF/jsp/
        suffix: .jsp
#配置redis信息
  redis:
    database: 0
    host: localhost
    password:
    port: 6379
    pool:
      max-idle: 8
      min-idle: 0
      max-active: 10
      max-wait: -1
server:
  sessionTimeout: 30

4. config

代码中有用到Spring的@Cacheable注解,RedisConfig中主要是讲RedisCacheManager配置成Spring全局的缓存管理器,这样在代码中使用@Cacheable注解的时候,默认都会使用Redis作为缓存的实现。同时还配置了一个keyGenerator。

在Spring-Boot中推荐使用注解的方式来配置对象,使用xml也行的,看个人喜好吧。

@Configuration
@EnableCaching
public class RedisConfig extends CachingConfigurerSupport {

    @Bean
    public KeyGenerator biliKeyGenerator(){
        return new KeyGenerator() {
            @Override
            public Object generate(Object target, Method method, Object... params) {
                StringBuilder sb = new StringBuilder();
                sb.append(target.getClass().getName());
                sb.append(method.getName());
                for (Object obj : params) {
                    sb.append(obj.toString());
                }
                return sb.toString();
            }
        };

    }

    @Bean
    public CacheManager cacheManager(@SuppressWarnings("rawtypes") RedisTemplate redisTemplate) {
        return new RedisCacheManager(redisTemplate);
    }

    @Bean
    public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
        StringRedisTemplate template = new StringRedisTemplate(factory);
        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
        ObjectMapper om = new ObjectMapper();
        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
        jackson2JsonRedisSerializer.setObjectMapper(om);
        template.setValueSerializer(jackson2JsonRedisSerializer);
        template.afterPropertiesSet();
        return template;
    }
}

5. model

很简单的一个User对象

@Entity
public class User implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    private Integer id;

    private String name;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

6. repository

JPA你值得拥有,就这么两行代码,基本的CRUD和分页都有了。

public interface UserDao extends PagingAndSortingRepository<User, Integer> {
}

7. service

service层逻辑很简单,也就不写接口了,直接一个实现。

@Cacheable注解会通过keyGenerator生成key,将方法的返回值作为value,存储到缓存管理器中,配置中的value这个字段,个人理解是相当于将缓存分成不同的块,每个块都有唯一的名字,通过value的值表明想要把这个方法的结果缓存到那一块中。比较像Redis中database的概念,不过没那么重。具体可以看一下这个annotation的注释。

@CacheEvict可用来刷新缓存

需要注意一点,如果被Cacheable注解的方法同时还有AOP,那么Cacheable会先于APO执行。

@Service
public class UserService {
    @Autowired
    private UserDao userDao;

    @Cacheable(value = "user_info", keyGenerator = "demoKeyGenerator")
    public User getById(Integer id) {
        System.out.println("从数据库中查询的");
        User user = userDao.findOne(id);
        return userDao.findOne(id);
    }

    @CacheEvict(value = "user_info", allEntries = true)
    public void update() {
        System.out.println("清除缓存");
    }
}

8. controller

@Controller
public class MainController {
    @Autowired
    private UserService userService;

    @RequestMapping(value = "/")
    public ModelAndView index() {
        //从数据库查询
        System.out.println(userService.getById(1).getName());

        //从缓存获取
        System.out.println(userService.getById(1).getName());

        //刷新缓存
        userService.update();

        //从数据库获取
        User user = userService.getById(1);
        System.out.println(user.getName());
        return new ModelAndView("index", "user", user);
    }
}

9. jsp

Hello, ${Your}!

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="com.francis.boot.model.User" %>
<html>
<head>
</head>
<body>
Hello, ${user.name}!
</body>
</html>

10. 程序入口

上面的逻辑代码跟其他的web项目也没什么区别,只是少写了一些xml配置,Spring-Boot如何自动映射这些配置,并根据配置和依赖的jar生成DataSource等对象呢? 主要是下面的代码在起作用。

Application(程序入口类,只是一个class的名字,而非只整个应用)这个class需要放到package的根目录下,主要是默认情况下Spring-Boot会扫描跟Application同级,以及级别比它低的目录里面的class。

//@Configuration
//@EnableAutoConfiguration(这个注解告诉Spring Boot根据添加的jar依赖猜测你想如何配置Spring。)
//@ComponentScan(如果被注解的类在类的根目录下,则可以不用指定basePackage)
//上面这三个注解通常都需要被放到main class,然后下面这个SpringBootApplication可以代替上面三个的功能
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(Application.class);
    }

    public static void main(String[] args) {
        ConfigurableApplicationContext configurableApplicationContext = SpringApplication.run(Application.class);
    }
}

至此,大功告成。

文件结构如下:
这里写图片描述

11. 其他

  • 日志默认使用logback
  • 内置容器对JSP的支持有一些限制。
    a. tomcat只支持war的打包方式,不支持可执行的jar。
    b. 内嵌的Jetty目前不支持JSPs。
    c. Undertow不支持JSPs
  • 如果只有接口,那么可以将程序打包成一个jar直接运行
Java餐馆管理系统:Spring Boot+MySQL实战 企业级应用开发中,B/S架构和关系型数据库是构建业务系统的核心技术组合。通过Spring Boot框架可以快速搭建Web应用,其自动配置特性显著提升开发效率;MySQL作为成熟的关系型数据库,能有效管理具有复杂关联的业务数据。在餐饮行业数字化场景中,这种技术栈特别适合处理订单管理、库存预警等高并发事务。本文以餐馆管理系统为例,详解如何利用Java技术栈实现包含收银、后厨、库存等模块的完整解决方案,其中涉及Spring Boot多环境配置、订单状态机等典型企业开发模式,以及应对并发下单、热销查询等实际业务挑战 阅读详情

相关推荐

Spring Boot+JSP实战:电子商务购物商城全流程设计与落地

本文介绍了一个基于Spring Boot 2.7.x和JSP技术的中小电商系统实现方案。该系统采用MVC分层架构,包含用户管理、商品管理、购物车、订单、支付等核心模块,解决了JSP与Spring Boot整合、购物车状态同步、订单事务一致性等关键问题。技术选型上强调开发效率和稳定性,使用MySQL+Redis保证数据一致性,通过JSP+Bootstrap实现快速视图开发。文章详细讲解了数据库设计、索引优化策略,并提供了Spring Boot配置JSP视图解析器的核心代码。该方案适合需要快速上线、维护成本低的

2601_94871597的博客 1148

Spring Boot+Bootstrap开发小而完整web项目

跟着本课程Demo完整的动手写一次,会发现你已经可以直接利用Spring Boot上手中小型web项目了。  Spring Boot框架是现在比较热门的微服务框架,很多软件公司都在使用,本课程涵盖Spring Boot和Bootstrap较为多面的知识点,针对Spring Boot开发web项目中每个阶段的关键内容和痛点,一步步进行条理清晰的讲解,学员在听课过程中建立起自己较为完备的前端、后端知识体系,具备较好的项目开展能力和自信。 课程特点是不炫技、条理清晰、生动浅显、化繁为简,每个章节都会围绕Spring Boot、Bootstrap的知识点“是什么、有什么用、怎么用”展开,并根据精心准备的简洁清晰的示例进行讲解。   学完该套课程后,可以很快上手Spring Boot实战开发,一个人就能完成一个基于Spring Boot+Bootstrap的完整WEB项目!  

Spring Boot:筑基

Spring Boot筑基

啊Q老师 6344

springboot基础篇(快速入门+要点总结)

本文详细的介绍了springboot的来源以及和spring的关系,和为什么使用springboot,然后介绍了两种搭建springboot项目的方法,以及热部署,properties配置文件的使用,在最后对于日志做出了详细的说明和用法。

zhaolk的博客 6万+

Spring Boot宠物商城实战源码:含MySQL建表脚本、JSP前端与完整配置

直接导入IDE就能跑的Java宠物电商系统,基于Spring Boot 2.x + MyBatis搭建,覆盖用户注册登录、宠物分类浏览、购物车增删改查、订单生成与状态管理等真实业务流程。项目结构清晰分层——Controller处理请求、Service封装逻辑、Mapper对接数据库,所有SQL语句通过MyBatis XML方式实现,支持动态条件查询和关联映射。配套jpetcoop.sql脚本已包含建库建表语句及初始化数据(如猫狗品种、示例用户、库存商品),适配本地MySQL 5.7+环境。前端采用JSP+J

stem5的博客 267

基于Java的在线考试系统:Spring Boot+MyBatis+Redis

在线考试系统是JavaWeb开发中的经典项目,涵盖用户认证、业务逻辑、数据库设计与部署上线等核心环节。其底层技术栈通常以Spring Boot作为基础框架,结合MyBatis实现数据持久化,并通过Redis解决验证码存储、考试令牌与题库缓存等并发场景问题。从系统设计角度看,数据库表结构决定了业务扩展性,而自动组卷算法与防重复提交机制则直接关系到考试公平性与系统稳定性。这一应用场景既适用于高校毕业设计,也可支撑企业内部培训考核。围绕此类系统的技术选型、核心算法与部署实践,对开发者提升工程能力具有实际参考价值。

weixin_30443747的博客 389

Springboot框架

springboot基本使用方法和配置方法

weixin_54204139的博客 3万+

Spring Boot电商项目实战:从SSM整合到Redis缓存与JWT认证

前后端分离架构是现代Web开发的标配,通过解耦前端展示与后端逻辑,既支持多端复用,也便于团队并行开发。Spring Boot作为Java后端的主流框架,以自动配置简化SSM整合,搭配MyBatis完成数据持久化;Redis凭借内存级读写性能,常被用于商品缓存、分布式锁等高频场景。基于这套技术栈构建的电商系统,天然覆盖用户认证、商品管理、订单一致性、库存扣减等核心业务,是验证后端工程能力的经典项目。本文从技术选型底层逻辑讲起,依次拆解数据库设计、接口规范、JWT无状态登录、缓存旁路模式、下单事务与防超卖实现,

weixin_29611239的博客 253

Springboot是什么?Springboot详解!入门介绍

Spring Boot的出现大大简化了Spring应用的初始搭建以及开发过程,让开发者快速启动新项目,把精力集中在代码编写和业务逻辑。

小明的Java问道之路 5万+

Java Web宠物网站实战:Spring+Struts2+JSP+MySQL整合开发全解析

在Java Web开发领域,MVC架构模式是构建企业级应用的核心思想,它将应用分为模型、视图和控制器三层,以实现关注点分离和代码复用。其工作原理是通过前端控制器拦截用户请求,分发给相应的处理器执行业务逻辑,并最终渲染视图返回响应。这种架构的技术价值在于提升了代码的可维护性、可测试性和团队协作效率,广泛应用于电商、内容管理、社交平台等各类Web系统。本文以宠物网站项目为具体场景,深入剖析如何将经典的Spring框架与Struts2进行整合,解决依赖注入与请求控制器的协同问题,并详细演示了使用JSP结合JSTL

weixin_34175509的博客 348

基于Spring Boot+Redis+WebSocket的医院排队叫号系统设计与实现

在并发编程中,队列是一种常见的数据结构,用于缓冲请求与任务,但在高并发场景下,如何保证队列操作的一致性与实时性却是一大挑战。Redis 提供了基于内存的 List 结构,配合 INCR 命令与乐观锁机制,可以高效实现 FIFO 队列与并发控制,而 WebSocket 长连接则能解决实时推送与轮询资源浪费的问题。这些技术组合在一起,恰好能落地为医院排队叫号系统的核心架构:自助机报到、医生叫号、大屏展示、状态流转(等待、叫号中、过号、回诊)都能得到可靠支撑。本文从通用队列原理出发,结合 Spring Boot、

weixin_27645199的博客 348

Spring Boot之添加JSP支持

truetrueprovidedjstlprovidedprovidedspring-web3.1.0fork : 如果没有该项配置,devtools不会起作用,即应用不会restarttrue3.添加配置文件#页面默认前缀#响应页面默认前缀4.创建jsp文件helloJsp${hello}5.创建controller。

2401_84009993的博客 1119

排列显示阿拉伯语、数字及英文时的处理方法

这段时间参与开发沙特阿拉伯的网站模板,模板使用的语言是阿拉伯语,其显示顺序为从右到左,而中文、数字及英文的显示顺序为从左到右 ,所以当遇到一行文字内既有阿拉伯语又有数字和英文时会出现语序混乱的问题,如 期待显示的文案为: 按顺序写入,对应的代码如以下,其中currency_pay为变量,值为356SAR <span>الدفع الفعلي:{{currency_pay}}</span> 显示为 الدفع الفعلي : 356SAR 金额356和货币符号SAR分开了,这样显

llq886的博客 5802

idea搭建spring boot+MongoDB+redis+mysql+activemq

1适合入门参照,比较全面,基于企业开发的最终极框架,全部所用最新版本(2018-10-26) 2加入对开发比较有好的BaseDAO 3反向生成实体类 1 new project 勾选: Core→DevTools(利于开发热部署),Lombok(实体类不用get,set了),Validation(后台参数校验), Web→web(项目支持web开发模式), Templat...

yang771036958的博客 2420

ABAP FB05 清账实战:POSTING_INTERFACE_CLEARING 核心参数与业务场景解析

本文深入解析ABAP FB05清账操作中的核心函数POSTING_INTERFACE_CLEARING,详细讲解其关键参数与业务场景应用。通过实战案例展示收款清账(EINGZAHL)流程,提供常见错误排查方法,并分享批量清账优化与财务凭证集成的高级技巧,帮助开发者高效处理SAP财务模块清账需求。

weixin_33423874的博客 475

CosyVoice 本地部署详细教程 手把手小白教程

本文提供了详细的CosyVoice本地部署教程,强调了避免中文名称和空格的重要性,并列出了必要的软件安装步骤,包括CUDA、cuDNN、Git和Miniconda。教程涵盖了从检查CUDA版本到下载模型和运行模型的全过程,确保用户能够顺利部署并使用CosyVoice。

huazn612的博客 2万+

学习Spring Boot的必读之书《深入浅出 Spring Boot 2.x》

首先,本书对比了传统 Spring 框架和 Spring Boot 的开发区别,并演示了搭建 Spring Boot 开发环境的过程,随后深入讲解了全注解下的Spring 基础 IoC 和 AOP 概念,使初学者能够轻松上手 Spring Boot 的全注解开发方式。是 Spring Boot 的核心重点,书中从 Spring MVC 的基础讲起,概述它的全流程处理和常见组件,随后深入讲解 Spring MVC 的开发和应用,帮助读者掌握各种 Spring Web 后端开发技巧。

8535

高通ISP模块全解析:从Raw到JPEG的18个关键处理步骤(附避坑指南)

本文全面解析高通ISP模块从Raw到JPEG的18个关键处理步骤,涵盖原始数据预处理、色彩科学处理链、画质增强与降噪等核心环节。通过实战调优经验,揭示ISP架构中的技术原理与工程实践要点,帮助开发者避免常见问题,提升移动影像处理质量。

weixin_30399155的博客 358

jsp登录功能的实现_Spring boot redis +mysql实现登录功能

在前面的文章中呢,我们介绍了spring boot 集成Druid,集成了mysql ,在实际的开发过程中呢,我们还需要利用redis 做一些缓存之类的数据,怎样去链接redis呢,本篇文章给大家讲解下,首先呢,我们还是需要去配置对应的库的。在我们的pom.xml去配置我们的redis。 org.springframework.boot spring...

weixin_39735012的博客 220

汽车软件工程师必看:ASPICE开发流程全解析(附各阶段交付物清单)

本文全面解析了汽车行业广泛采用的ASPICE开发流程,详细介绍了从需求挖掘到系统架构设计、软件工程及测试验证各阶段的关键操作和交付物清单。针对汽车软件工程师,提供了实用的协作指南和工具推荐,帮助团队提升开发效率并降低项目风险,是掌握ASPICE标准的必备指南。

weixin_30733003的博客 639

手把手教你用树莓派蓝牙抓取小米温湿度计2代数据,接入HomeAssistant(附密钥获取避坑指南)

本文详细介绍了如何通过树莓派蓝牙抓取小米温湿度计2代数据并接入HomeAssistant的完整流程。重点解析了获取32位加密密钥的三种方法,包括使用Telink Flasher工具、米家APP抓包和开源工具ATC_MiThermometer,并提供了HomeAssistant集成配置和常见问题排查指南,帮助用户实现稳定可靠的温湿度监测。

一名菜鸟攻城师 779

Docker部署Spring boot + Redis +Mysql

在docker上部署Spring boot,并连接docker上的redis、mysql

liyayou的博客 1155

肖特基二极管选型参数,结构原理,工艺与注意问题总结

肖特基二极管(Schottky Diode)是一种特殊的二极管,也被称为肖特基势垒二极管。它是利用金属与半导体接触形成的金属-半导体结原理制成的。与传统的PN结二极管相比,肖特基二极管具有更低的正向压降、更高的开关速度、更高的反向恢复时间以及更好的温度稳定性等特点。本文对肖特基二极管的工作原理,结构特点,工艺流程,选型参数及设计注意事项进行总结。

fydar的博客 812

(课程设计)spring boot大学毕业设计管理系统 毕业设计 附源码 030945

使用大学毕业设计管理系统的分为管理员和用户、两个权限模块。 管理员所能使用的功能主要有首页、站点管理(轮播图、公告栏)用户管理(管理员、学生用户、教师用户、院系领导)内容管理(校园资讯、校园资讯分类)更多管理(毕设课题、选择信息、任务书、开题报告、中期报告、毕业论文、答辩通知、毕设通知、成绩汇总、课题分类)等。 学生可以实现首页、选择信息、任务书、开题报告、中期报告、毕业论文、答辩通知、毕设通知。 教师可以实现首页、毕设课题、选择信息、任务书、开题报告、中期报告、毕业论文、毕设通知、成绩汇总等...

ID3461074420的博客 1万+

安卓App开发 篇三:Android SDK和API

Jetpack 是一个由多个库组成的套件,可帮助开发者遵循最佳做法、减少模板代码并编写可在各种 Android 版本和设备中一致运行的代码,让开发者可将精力集中于真正重要的编码工作。hl=zh-cnhl=zh-cnWorkManager 是 Android Jetpack 的一部分,是用于持久性工作的推荐解决方案,适用于需要通过应用重启和系统重新启动来调度的工作,也是后台处理操作的主要推荐 API。立即执行:必须立即开始且很快完成的任务,可以加急,使用和Worker,通过对调用处理加急工作。

生活在别处 1280

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

打造你的专属博客:基于Spring Boot的个人博客系统

打造你的专属博客:基于Spring Boot的个人博客系统 去发现同类优质开源项目:https://gitcode.com/ 项目介绍 在数字化时代,个人博客不仅是展示自我、分享知识的平台,更是技术学习和实践的绝佳场所。基于Spring Boot的个人博客系统,正是为满足这一需求而生的开源项目。无论你是计算机专业的学生,还是热衷于技术分享的开发者,这个项目都能为你提供一个坚实的基础,帮助你快速搭建...

gitblog_09704的博客 443

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

上一篇: Spring使用Ehcache
下一篇: SpringBoot集成Swagger
java_4_ever
博客等级 码龄16年 8粉丝 29原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值