《Spring Boot in Action》【6. Grails】

Spring Boot in Action A developer-focused guide to writing applications using Spring Boot. You'll learn how to bypass the tedious configuration steps so that you can concentrate on your application's behavior., Spring Boot in Action is a developer-focused guide to writing applications using Spring Boot. In it, you?ll learn how to bypass configuration steps so you can focus on your application?s behavior. Spring expert Craig Walls uses interesting and practical examples to teach you both how to use the default settings effectively and how to override and customize Spring Boot for your unique environment. Along the way, you?ll pick up insights from Craig?s years of Spring development experience. 立即下载

6. Grails

6.1 使用GORM持久化数据

GORM(Grails object-relational mapping)Book实体:

package readinglist

import grails.persistence.*

@Entity
class Book {
  Reader reader
  String isbn
  String title
  String author
  String description
}

要在Spring Boot项目中使用GORM,加入依赖:

compile("org.grails:gorm-hibernate4-spring-boot:1.1.0.RELEASE")

这是通过Hibernate,如果你使用MongoDB,也是可以的:

compile("org.grails:gorm-mongodb-spring-boot:1.1.0.RELEASE")

GORM Reader实体:

package readinglist
import grails.persistence.*

import org.springframework.security.core.GrantedAuthority
import org.springframework.security.core.authority.SimpleGrantedAuthority
import org.springframework.security.core.userdetails.UserDetails

@Entity
class Reader implements UserDetails {

  String username
  String fullname
  String password

  Collection<? extends GrantedAuthority> getAuthorities() {
    Arrays.asList(new SimpleGrantedAuthority("READER"))
  }

  boolean isAccountNonExpired() {
    true
  }

  boolean isAccountNonLocked() {
    true
  }

  boolean isCredentialsNonExpired() {
    true
  }

  boolean isEnabled() {
    true
  }
}

ReadingListController

package readinglist

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.http.HttpStatus
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.ResponseStatus

@Controller
@RequestMapping("/")
@ConfigurationProperties("amazon")
class ReadingListController {

  @Autowired
  AmazonProperties amazonProperties

  @ExceptionHandler(value=RuntimeException.class)
  @ResponseStatus(value=HttpStatus.BANDWIDTH_LIMIT_EXCEEDED)
  def error() {
    "error"
  }

  @RequestMapping(method=RequestMethod.GET)
  def readersBooks(Reader reader, Model model) {
    List<Book> readingList = Book.findAllByReader(reader)
    model.addAttribute("reader", reader)
    if (readingList) {
      model.addAttribute("books", readingList)
      model.addAttribute("amazonID", amazonProperties.getAssociateId())
    }
    "readingList"
  }

  @RequestMapping(method=RequestMethod.POST)
  def addToReadingList(Reader reader, Book book) {
    Book.withTransaction {
      book.setReader(reader)
      book.save()
    }
    "redirect:/"
  }
}

Groovy SecurityConfig:

package readinglist

import org.springframework.context.annotation.Configuration
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.WebSecurityConfigurerAdapter
import org.springframework.security.core.userdetails.UserDetailsService

@Configuration
class SecurityConfig extends WebSecurityConfigurerAdapter {

  void configure(HttpSecurity http) throws Exception {
    http
      .authorizeRequests()
        .antMatchers("/").access("hasRole('READER')")
        .antMatchers("/**").permitAll()
      .and()
      .formLogin()
        .loginPage("/login")
        .failureUrl("/login?error=true")
  }

  void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth
      .userDetailsService(
        { username -> Reader.findByUsername(username) }
        as UserDetailsService)
  }
}

6.2 用GSP编写视图

目前为止我们都是使用Thymeleaf作为模板引擎,Grails项目同时提供了Groovy Server Pages(GSP)的自动配置,添加如下依赖:

compile("org.grails:grails-gsp-spring-boot:1.0.0")

接下来,把Thymeleaf readingList.html改写成readingList.gsp,同样是放在src/main/resources/templates路径下:

<!DOCTYPE html>
<html>
  <head>
    <title>Reading List</title>
    <link rel="stylesheet" href="/style.css"></link>
  </head>

  <body>
    <h2>Your Reading List</h2>

    <g:if test="${books}">
    <g:each in="${books}" var="book">
      <dl>
        <dt class="bookHeadline">
          ${book.title} by ${book.author}
          (ISBN: ${book.isbn}")
        </dt>
        <dd class="bookDescription">
          <g:if test="book.description">
            ${book.description}
          </g:if>
          <g:else>
            No description available
          </g:else>
        </dd>
      </dl>
    </g:each>
    </g:if>
    <g:else>
      <p>You have no books in your book list</p>
    </g:else>

    <hr/>

    <h3>Add a book</h3>

    <form method="POST">
      <label for="title">Title:</label>
      <input type="text" name="title" 
                         value="${book?.title}"/><br/>
      <label for="author">Author:</label>
      <input type="text" name="author"
                         value="${book?.author}"/><br/>
      <label for="isbn">ISBN:</label>
      <input type="text" name="isbn"
                         value="${book?.isbn}"/><br/>
      <label for="description">Description:</label><br/>
      <textarea name="description" rows="5" cols="80">
        ${book?.description}
      </textarea>
      <input type="hidden" name="${_csrf.parameterName}"
           value="${_csrf.token}" />
      <input type="submit" value="Add Book" />
    </form>

  </body>
</html>

需要注意的是,我们有一个隐藏域来放CSRF(Cross-Site Request Forgery)token,Spring Security要求在POST请求中有这个token,Thymeleaf会自动在渲染的HTML中加入这个token,但在GSP中,你得显式指定。

6.3 混合Spring Boot和Grails 3

Grails是一个建立在Spring,Groovy,Hibernate等之上的高层框架,目前,Grails 3建立在Spring Boot之上,所以对于Grails开发者和Spring Boot开发者来说,都有很好的开发体验。

在Mac OS X和大部分Unix系统上,安装Grails最方便的方法是使用SDKMAN:

$ sdk install grails

在Windows或者不能使用SDKMAN的系统上,你只好下载,解压并把bin目录添加到环境变量里去,检查安装是否成功:

$ grails -version

创建Grails项目

$ grails create-app readinglist

运行:

$ grails run-app

因为Grails 3的Gradle脚本使用了Spring Boot插件,所以也可以使用bootRun运行:

$ gradle bootRun

当然也可以打包运行:

$ gradle build
...
$ java -jar build/lib/readingList-0.1.jar

定义domain

$ grails create-domain-class Book

它会创建两个文件:Book.groovy和BookSpec.groovy,后面一个文件是测试Book类的Spock specification,初始是空的,Book.groovy在grails-app/domain/readingList目录下,像这样:

package readinglist

class Book {

  static constraints = {
  }
}

我们添加一些字段:

package readinglist

class Book {

  static constraints = {
  }

  String reader
  String isbn
  String title
  String author
  String description
}

静态变量constraints是用来定义验证约束的,这里我们不关心。

编写Grails控制器

有几种命令可以创建Controller:

  • create-controller——创建一个空的Controller
  • generate-controller——生成包含指定domain类型CRUD操作的骨架Controller
  • generate-all——生成包含指定domain类型CRUD操作的骨架Controller以及视图

我们使用第一个:

$ grails create-controller ReadingList

该命令会在grails-app/controllers/readingList目录下创建一个ReadingListController:

package readinglist

class ReadingListController {

  def index() { }
}

此时该控制器已经可以处理/readingList请求了,会返回grails-app/views/readingList/index.gsp视图(暂时还不存在)

package readinglist

import static org.springframework.http.HttpStatus.*
import grails.transaction.Transactional

class ReadingListController {

  def index() {
    respond Book.list(params), model:[book: new Book()]
  }

  @Transactional
  def save(Book book) {
    book.reader = 'Craig'
    book.save flush:true
    redirect(action: "index")
  }
}

接下来就是编写GSP页面,和6.2中的差不多:

<!DOCTYPE html>
<html>
  <head>
    <meta name="layout" content="main"/>
    <title>Reading List</title>
    <link rel="stylesheet"
          href="/assets/main.css?compile=false"  />
    <link rel="stylesheet"
          href="/assets/mobile.css?compile=false"  />
    <link rel="stylesheet"
          href="/assets/application.css?compile=false"  />
  </head>

  <body>
  <h2>Your Reading List</h2>

  <g:if test="${bookList && !bookList.isEmpty()}">
    <g:each in="${bookList}" var="book">
    <dl>
      <dt class="bookHeadline">
        ${book.title}</span> by ${book.author}
        (ISBN: ${book.isbn}")
      </dt>
      <dd class="bookDescription">
        <g:if test="${book.description}">
        ${book.description}
        </g:if>
        <g:else>
        No description available
        </g:else>
      </dd>
    </dl>
    </g:each>
  </g:if>
  <g:else>
    <p>You have no books in your book list</p>
  </g:else>

  <hr/>

  <h3>Add a book</h3>

  <g:form action="save">
  <fieldset class="form">
    <label for="title">Title:</label>
    <g:field type="text" name="title" value="${book?.title}"/><br/>
    <label for="author">Author:</label>
    <g:field type="text" name="author" value="${book?.author}"/><br/>
    <label for="isbn">ISBN:</label>
    <g:field type="text" name="isbn" value="${book?.isbn}"/><br/>
    <label for="description">Description:</label><br/>
    <g:textArea name="description" value="${book?.description}" rows="5" cols="80"/>
  </fieldset>
  <fieldset class="buttons">
    <g:submitButton name="create" class="save"
      value="${message(code: 'default.button.create.label', default: 'Create')}" />
  </fieldset>
  </g:form>

  </body>
</html>
Spring.Boot.in.Action.2015.12.pdf Spring.Boot.in.Action.2015.12.pdfFor online information and ordering of this and other manning books, please visit www.manning.com.thepublisheroffersdiscountsonthisbookwhenorderedinquantity For more information, please contact Special sales department Manning publications co 20 Baldwin Road PO BoX 761 Shelter island. ny11964 Emailorders@manning.com @2016 by manning Publications Co. All rights reserved No part of this publication may be reproduced, stored in a retrieval system, or transmitted,in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and manning Publications was aware of a trademark claim, the designations have been printed in initial caps ll Recognizing the importance of preserving what has been written, it is Mannings policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine Manning publications co Development editor: Cynthia Kane 20 Baldwin Road Technical development editor: Robert casazza PO BoX 761 Copyeditor: Andy Carroll Shelter island. ny11964 Proofreader: Corbin Collins Technical p der John Guthrie Typesetter: Gordan Salinovic Cover designer: Marija Tudor ISBN9781617292545 Printed in the united states of america 12345678910-EBM-201918171615 contents reword vii pre eface 2x about this book xii acknowledgments xu Bootstarting Spring I 1. 1 Spring rebooted Taking a fresh look at spring 2. Examining spring Boot essentials 4 What Spring Boot isn't 7 1.2 Getting started with Spring boot 8 Installing the spring boot cli 8 Initializing a spring boot project with Spring Initializr 12 3 Summary 22 Developing your first Spring Boot application 23 2.1 Putting spring boot to work 24 Examining a newly initialized spring boot project 26 Dissecting Bc iect build 30 2.2 USing starter dependencies 33 Specifying facet-based dependencies 34. Overriding starter transitive dependencies 35 CONTENTS 2.8 USing automatic configuration 37 Focusing on application functionality 37. Running the application 45. What just happened? 45 2.4 Summary 48 Customizing configuration 49 8.1 Overriding Spring Boot auto-configuration 50 Securing the application 50. Creating a custom security configuration 51. Taking another peek under the covers of auto-configuration55 8.2 Externalizing configuration with properties 57 Fine-tuning auto-configuration 58. Externally configuring application beans 64. Configuring with profiles 69 8.8 Customizing application error pages 71 3.4 Summary 74 Testing with Spring Boot 76 4.1 Integration testing auto-configuration 77 4.2 Testing web applications 79 Mocking spring MvC 80- Testing web security 83 4.3 Testing a running application 86 Starting the server on a random port 87. Testing HTML pages with selenium 88 4.4 Summary 90 Getting Groovy with the spring Boot CLI 92 5.1 Developing a Spring Boot CLI application 93 Setting up the cli project 93 Eliminating code noise with Groovy 94. What just happened? 98 5.2 Grabbing dependencies 100 Overriding default dependency versions 101. Adding dependency repositories 102 5.8 Running tests with the CLI 102 5.4 Creating a deployable artifact 105 5.5 Summary 106 CONTENTS 6 Applying Grails in Spring Boot 107 1 Using gorm for data persistence 108 2 Defining views with groovy server pages 113 6.3 Mixing spring boot with grails 3 115 Creating a new grails project 116 Defining the domain 118 Writing a grails controller 119. Creating the view 120 6.4 Summary 123 Taking a peek inside with the Actuator 124 7.1 Exploring the actuator's endpoints 125 Viewing configuration details 126. Tapping runtime metrics 133 Shutting down the application 139. Fetching application information 140 7.2 Connecting to the Actuator remote shell 141 Viewing the autoconfig report 142. Listing application beans 143 Watching application metrics 144.Invoking actuator endpoints 145 7. 3 Monitoring your application with JMX 146 7.4 Customizing the Actuator 148 Changing endpoint Ds 148 Enabling and disabling endpoints 149 Adding custom metrics and gauges 149- Creating a custom trace repository 153 Plugging in custom health indicators 155 7.5 Securing Actuator endpoints 156 7.6 Summary 159 8 Deploying Spring Boot applications 160 8.1 Weighing deployment options 161 8.2 Deploying to an application server 162 Building a WaRfile 162 Creating a production profile Enabling database migration 168 8.3 Pushing to the cloud 173 Deploying to Cloud Foundry 173 Deploying to Heroku 177 8. Summary 180 appendix a spring Boot developer Tools 187 appendix b spring Boot starters 188 appendix c Configuration properties 195 appendix d spring boot dependencies 232 index 243 In the spring of 2014, the Delivery Engineering team at Netflix set out to achieve a lofty goal: enable end-to-end global continuous delivery via a software platform that facilitates both extensibility and resiliency. my team had previously built two different applications attempting to address Netflix's delivery and deployment needs, but both were beginning to show the telltale signs of monolith-ness and neither met the goals of flexibility and resiliency. What's more, the most stymieing effect of these monolithic applications was ultimately that we were unable to keep pace with our partner's inno- vation. Users had begun to move around our tools rather than with them It became apparent that if we wanted to provide real value to the company and rap- idly innovate, we needed to break up the monoliths into small, independent services that could be released at will. Embracing a microservice architecture gave us hope that we could also address the twin goals of flexibility and resiliency. but we needed to do it on a credible foundation where we could count on real concurrency, legitimate moni- toring, reliable and easy service discovery, and great runtime performance With the jVM as our bedrock, we looked for a framework that would give us rapid velocity and steadfast operationalization out of the box. We zeroed in on Spring Boot Spring Boot makes it effortless to create Spring-powered, production-ready ser- vices without a lot of code! Indeed, the fact that a simple Spring Boot Hello World application can fit into a tweet is a radical departure from what the same functionality required on the vm only a few short years ago. Out-of-the-box nonfunctional features like security, metrics, health-checks, embedded servers, and externalized configura tion made boot an easy choice for us FOREWORD Yet, when we embarked on our Spring boot journey solid documentation was hard to come by. Relying on source code isnt the most joyful manner of figuring out how to properly leverage a frameworks features It's not surprising to see the author of mannings venerable Spring in Action take on the challenge of concisely distilling the core aspects of working with Spring Boot into another cogent book. Nor is it surprising that Craig and the Manning crew have done another tremendously wonderful job! Spring Boot in Action is an easily readable book, as weve now come to expect from Craig and manning From chapter Is attention-getting introduction to Boot and the now legend ary 9Oish-character tweetable Boot application to an in-depth analysis of Boots Actuator in chapter 7, which enables a host of auto-magical operational features required for any production application, Spring Boot in Action leaves no stone unturned. Indeed, for me, chapter 7's deep dive into the Actuator answered some of the lingering questions I've had in the back of my head since picking up Boot well over a year ago. Chapter 8s thor- ough examination of deployment options opened my eyes to the simplicity of cloud Foundry for cloud deployments. One of my favorite chapters is chapter 4, where Craig explores the many powerful options for easily testing a Boot application. From the get- o, I was pleasantly surprised with some of Springs testing features, and boot takes g advantage of them nicely As I've publicly stated before, Spring Boot is just the kind of framework the Java community has been seeking for over a decade. Its easy-to-use development features and out-of-the-box operationalization make java development fun again I,m pleased to report that Spring and spring boot are the foundation of Netflix's new continuous delivery platform. What's more, other teams at Netflix are following the same path because they too see the myriad benefits of boot It's with equal parts excitement and passion that I absolutely endorse craigs book as the easy-to-digest and fun-to-read Spring boot documentation the Java community has been waiting for since Boot took the community by storm. Craigs accessible writ- ing style and sweeping analysis of boot's core features and functionality will surely leave readers with a solid grasp of Boot(along with a joyful sense of awe for it) Keep up the great work Craig Manning Publications, and all the brilliant develop ers who have made spring boot what it is today each one of you has ensured a bright future for the JV ANDREW GLOVER MANAGER, DELIVERY ENGINEERING AT NETFLIX preface At the 1964 New York World's Fair, Walt Disney introduced three groundbreaking attractions:"“it' s a small world,”“ Great Moments with mr. Lincoln," and the“ Carouse of Progress " All three of these attractions have since moved into disneyland and walt Disney world, and you can still see them today My favorite of these is the Carousel of Progress. Supposedly, it was one of Walt Disneys favorites too. It's part ride and part stage show where the seating area rotates around a center area featuring four stages. Each stage tells the story of a family at different time periods of the 20th century-the early 1900s, the 1920s the 1940s, and recent times-highlighting the technology advances in that time period The story of innovation is told from a hand-cranked washing machine, to electric lighting and radio, to automatic dishwashers and television, to computers and voice-activated appliances In every act, the father (who is also the narrator of the show)talks about the latest inventions and says "It cant get any better only to discover that in fact, it does get better in the next act as technology progresses Although Spring doesn't have quite as long a history as that displayed in the Car- ousel of Progress, I feel the same way about Spring as"Progress Dad felt about the 20th century. Each and every Spring application seems to make the lives of developers so much better. Just looking at how Spring components are declared and wired together, we can see the following progression over the history of Spring 立即下载

相关推荐

grails-boot:Grails 与 Spring Boot 的集成

grails-boot Grails 与 Spring Boot 的集成 GORM Spring Boot 插件已移至

Groovy&Grails理解–第2部分

ils子 Grails是基于Groovy和Java的Web框架,可以将其部署到现有的Java Web服务器中,例如Tomcat或Jetty。 它的脚手架功能使您可以在几分钟内创建一个新项目。 Grails基于“基于配置的约定”的思想,该思想允许应用程序根据命名方案(而不是使用配置文件,例如XML文件)自动连接自身。 Grails框架无需任何配置即可进行实例开发。 Grails通过在开发过...

400

Win11 C盘爆满别慌!手把手教你安全迁移AppData和用户文件夹(附一键脚本)

本文针对Win11 C盘空间不足问题,提供了一套安全有效的解决方案。通过深入解析用户目录结构,指导用户利用符号链接和Robocopy工具,将AppData、下载文档等占用大户迁移至其他分区,并附带了自动化脚本,从根本上实现C盘瘦身,同时确保系统稳定和数据安全。

weixin_29231221的博客 2084

grails springboot_Spring Boot 和 Grails 的不同点

最近花了些时间了解了一下 Spring Boot 这个新框架。这个框架提供了快速开发基于 Spring Framework 的应用的功能。同样,SpringSource 旗下还有另一个用于 Web 应用快速开发的框架,就是 Grails。初看来这两个框架有很多相似的地方,所以可以将这两个框架做一下对比。Spring Boot 强调自运行;Grails 应用则需要打包成 WAR 来运行当然 Grai...

weixin_42400619的博客 542

python音频信号分析

声音以具有诸如频率、带宽、分贝等参数的音频信号的形式表示,典型的音频信号可以表示为幅度和时间的函数

MAY的博客 2785

DeepMD-kit描述子机制解析:从原子坐标到不变性特征

本文深入解析DeepMD-kit描述子机制,详细阐述如何将原子坐标转换为具有平移、旋转和排列不变性的特征表示。探讨了se_e2_a、se_e3等不同描述子的适用场景及性能优化技巧,帮助读者掌握这一关键技术在分子模拟中的应用实践。

weixin_42520661的博客 340

SpringBoot in Action——初识SpringBoot

现在,我们里利用了整本书的篇幅来介绍Spring。尽管Spring带来的主要益处就是简化Java开发,但本章将会介绍Spring Boot如何让这项任务变得更简单。 Spring Boot在Spring之上,构建了全新的开发模式,移除了开发Spring应用中很多单调乏味的东西。 我们首先整体了解一下Spring Boot,看它是怎么简化Spring的。 Spring Boot简介 在Spring家...

No_Game_No_Life_的博客 1770

Python实战:5分钟搞定VCF文件中每个样本的SNP统计(附bcftools安装指南)

本文介绍了三种高效统计VCF文件中每个样本SNP数量的Python方法,包括原生解析、结合bcftools的推荐方案以及使用PyVCF3专业库。特别推荐bcftools结合Python的方法,适用于中大型VCF文件,显著提升处理效率。文章还提供了bcftools安装指南和进阶统计技巧,帮助生物信息学分析人员快速完成SNP统计任务。

weixin_30555125的博客 493

Groovy in Action 开源项目指南

Groovy in Action 开源项目指南 1. 项目介绍 Groovy in Action 是一个旨在深入探索Groovy编程语言特性的开源项目。该项目基于GitHub,由Dierk King开发维护(GitHub仓库)。它不仅提供了一个学习Groovy语言高级功能的平台,而且还通过示例和实际应用来展示如何有效地将Groovy融入到日常开发中,适合希望深入理解和掌握Groovy语言的开发者。...

gitblog_00796的博客 458

芒果YOLOv12改进13:独家原创改进最新 CFNet 核心结构|即插即用 | 首发改进显著提升检测性能,小目标检测涨点必备

芒果YOLOv12改进13:独家原创改进最新 CFNet 核心结构|即插即用 | 首发改进显著提升检测性能,小目标检测涨点必备

包括YOLOv5、YOLOv7、YOLOv8等模型改进 285

端到端自动驾驶:特斯拉FSD Beta技术拆解

端到端自动驾驶:特斯拉FSD Beta技术拆解 ,人工智能,计算机视觉,大模型,AI,这篇文章围绕特斯拉FSD Beta的端到端自动驾驶技术展开,先介绍端到端自动驾驶的定义、与传统方案的区别及FSD Beta的特点,再阐述其硬件基础、技术架构,解析关键技术,还涉及训练数据与标注、安全与冗余设计、实际应用场景与挑战以及技术迭代与更新等内容,展现了该技术的多方面情况。

不踩坑,不知道坑有多深;不总结,踩过的坑白踩。 18万+

Wand-Enhancer 完整指南:三步本地客户端补丁解锁专业版体验

Wand(原 WeMod)免费用户每天只有 2 小时额度,超时弹提示、AI 功能锁在付费墙后。开源项目 Wand-Enhancer 用一个本地客户端补丁把这件事解决掉:不连服务器、不发任何网络请求,只改写你自己电脑里客户端归档中的限制配置,把免费版体验抬到专业版水平。 ## 项目速览:Wand-Enhancer 是什么、由哪些模块组成 Wand-Enhancer 是面向 Wand(原 WeMo

gitblog_00512的博客 680

【用unity实现100个游戏之7】实现一个类《杀戮尖塔》的卡牌回合制游戏(附项目源码)

【用unity实现100个游戏之7】实现一个类《杀戮尖塔》的卡牌回合制游戏(附项目源码)

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 1万+

Maven镜像配置全解析:原理、国内镜像源对比与多环境实战指南

在Java项目构建中,依赖管理是核心环节,Maven作为主流构建工具,其仓库机制负责从远程服务器下载和管理项目所需的库文件。其工作原理是通过解析pom.xml文件中的依赖声明,从配置的仓库地址获取构件。为了提升下载速度与稳定性,特别是在网络环境复杂的情况下,**仓库镜像**技术应运而生,它通过在国内部署缓存节点,将远程仓库的请求重定向到本地或更近的服务器,从而显著加速依赖解析和下载过程,这对于提升研发效率和保障构建流程的可靠性具有重要价值。常见的应用场景包括个人开发环境配置、团队协作统一以及持续集成流水线的

weixin_30407613的博客 413

Jetson AGX Orin平台Jetpack5升级Jetpack6,自研载板USB不工作问题调试

1. 问题描述将AGX Orin工业的新板放到定制的载板上当在ubuntu 22和Jetpack 6.1上使用SDKManager刷机时,lsusb为空,并且在引导时没有发现/注册xusb设备。USB C端口正常打开并供电,但似乎没有数据传输。在Ubuntu 18 Jetpack 5.1.4 SDKManager上同样刷机之后,usb C集线器在引导时被正确地发现,显示在lsusb中,并识别/挂载外部驱动器。

jzwjzw19900922的博客 1509

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

探索Spring Boot in Action:一款高效的Java开发工具

探索Spring Boot in Action:一款高效的Java开发工具 是一个开源项目,旨在帮助开发者更快速、更高效地构建基于Spring Boot的应用程序。该项目由 Hanson Wang 提供,它不仅是一个代码库,还是一份详细的学习资源,涵盖了Spring Boot的核心概念和实践技巧。 技术分析 1. Spring Boot: Spring Boot是Spring框架的一个扩展,它简化...

gitblog_00034的博客 522

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

SpringBoot in Action——自定义配置

在传统的Spring配置的过程,就如同订比萨的时候自己指定全部的辅料。而Spring Boot自动配置就像是从菜单上选一份特色比萨,让Spring Boot处理各种细节比自己声明上下文里全部的Bean要容易很多。 幸运的是,Spring Boot自动配置非常灵活。就像比萨厨师可以不在你的比萨里放蘑菇,而是加墨西哥胡椒一样,Spring Boot能让你参与进来,影响自动配置的实施。 覆盖Spring...

No_Game_No_Life_的博客 805

Spring-Boot-与-Grails-3相结合可以完成什么?,kafka快速入门

$ gradle bootRun 你还可以构建项目,运行生成的可执行JAR文件: $ gradle build … $ java -jar build/lib/readingList-0.1.jar 当然,构建产生的WAR文件可以部署到你喜欢的各种Servlet 3.0容器里。 在开发早期就能运行应用程序,这一点十分方便,能帮你确认应用程序已正确初始化。但是这时应用程序还没做什么有意思的事情,在初始化后的项目上做什么完全取决于我们。接下来,开始定义领域模型吧。 二、定义领域模型 阅读列表应用程序里的核心领域

m0_64384350的博客 345

《Spring Boot in Action》【2. 开发第一个应用】

2 开发第一个应用2.1 项目骨架从本章开始,我们要开发一个简单的reading-list应用,用来维护一个reading-list,包括录入书的信息,查看阅读列表,删除书等操作。技术上,Spring MVC处理Web请求,Thymeleaf作为模板引擎编写页面,Spring Data JPA操作数据库,使用内置H2数据库,用Gradle管理项目。使用Spring Initializer生成生成的项

极客神殿 907

《Spring Boot in Action》【1. 起步】

1 起步 Spring 1.0,改变了企业级Java应用开发。依赖注入和声明式事务。 Spring 2.0,自定义XML命名空间。 Spring 2.5,面向注解的依赖注入模型,@Component和@Autowired,以及Spring MVC编程模型。无需显式声明组件,无需继承一些基础控制器类。 Spring 3.0,全新的基于Java的配置方式,从Spring 3.1开始的@Enable打头的

极客神殿 2240

gradle环境的spring boot搭建

类似于maven,但有比maven更佳简洁的语法,整体看起来比maven更加的方便管理,可能是未来的一个趋势。建议:先使用maven环境搭建spring boot并且对maven环境的项目应用有一定基础后再使用gradle可以更快上手应用,因为这两个东西其实很像。

感谢阅读 3520

Spring-boot IN Action(1)

之前在写Spring入门的学习笔记,但是深深感受到单单是“硬学”,即便有穿插一些生动的小例子,还是远远不能用好Spring,更不用谈掌握其核心,深入理解它的思想了。不得不承认,项目是进步的原动力,很复杂的思想、理念,经历几个项目,相信大家都能用的很熟,也会有一定的理解了,辅之以一些参考文档,大神的思想解析,便能够做到游刃有余地利用Spring,而不是被Spring的各种配置,各种思想、各种模式搞得

积跬步,至千里 1434

Grails和Spring Boot都是优秀的Java Web应用开发框架,它们各有特点,适用于不同的场景,因此很难简单地说哪个更好

我很高兴地宣布Grails 1.3的即时可用性!Grails发行版的追随者们会记得,Grails的上一个主要发行版(Grails 1.2是在12月份发布的)已经不长了,但是考虑到需要让开发人员掌握最新、最棒的Groovy版本,grails1.3可以被看作是groovy1.7发行版。Groovy团队为Groovy语言带来了各种优秀的新功能,比如无注释的内部/嵌套类、AST构建器和power asserts(我个人最喜欢的),所有这些功能现在都可以在Grails应用程序中使用。

[Blog][Domain] programb.blog.youkuaiyun.com 429

【项目推荐】基于 SpringBoot3 + Spring AI 的游泳馆管理系统:Agent + RAG + Function Calling 一次学全

它不是玩具 Demo,而是一个「业务 + AI」双主线交织的真实系统——预约业务在跑,AI 客服在旁边实时查库作答,两条线通过 Function Calling、RAG、站内消息串成一体。面试官问「你做过什么 AI 项目」时,你能从业务场景讲到架构取舍,从 RAG 切分参数讲到降级兜底——这和「我调了一下 ChatGPT 的 API」是完全不同的两个段位。项目已包含完整的建表 SQL、初始化数据、部署文档,克隆下来就能跑。获取方式:见文末说明 / 后台回复关键词获取。—— 完 ——

深耕开发,专注编程实战。分享源码解析、项目搭建、问题排查笔记,沉淀技术,持续更新。 336
上一篇: 《Spring Boot in Action》【5. Groovy】
下一篇: 《Spring Boot in Action》【7. Actuator】
.NET跨平台
博客等级 码龄15年 6066粉丝 738原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值