idea下打包 SpringBoot 项目并部署到 Linux 服务器

ideal一键部署SpringBoot项目jar包到服务器 我们在开发环境部署项目一般通过ideal将项目打包成jar包,然后连接linux服务器,将jar手动上传到服务中,重启服务。每次总是循环这一系列的操作,这都是一些固定的流水线操作,对于流水线型的操作最适合交给程序去做,我们只需要把那些个必要变量(路径/端口)抽离出来变成外部配置文件,这样我们就完全可以实现自定义流水线操作。 阅读详情

本文主要记录了如何在 idea 下打包 SpringBoot 项目并部署到云服务器,包括jar包和war包两种方式。

2022.11.23 更新了一下图片地址和链接,几次博客迁移导致超链接都失效了,不过发现偶尔还是会增加阅读量,于是更新一下,虽然现在没写 Java 了。。。

更多文章欢迎访问我的个人博客–>指月小筑

1. 创建项目

首先简单创建一个hello word

代码如下:

/**
 * 简单的controller
 *
 * @author lixd
 */
@RestController
public class HelloController {
    @RequestMapping(value = "/hello")
    public String showHello() {
        return "hello world";
    }
}

/**
 * SpringBoot启动类
 *
 * @author lixd
 */
@SpringBootApplication
public class HelloApplication {

    public static void main(String[] args) {
        SpringApplication.run(HelloApplication.class, args);
    }

}

2. 打包

2.1 jar包和war包区别

  • SpringBoot默认支持很多模板引擎,但是JSP只能够在War中使用
  • 无论是Jar还是War都能够使用嵌套容器,java -jar来独立运行
  • 但只有war才能部署到外部容器中

2.2 jar包

SpringBoot官方推荐打成jar包,服务器上有JDK 1.8以上环境就可以直接运行

1.修改pom.xml文件

选择打包方式为jar

    <groupId>com.illusory</groupId>
    <artifactId>hello</artifactId>
    <version>0.0.1-SNAPSHOT</version>    <!--版本号-->
    <name>hello</name>   		 <!--打出来的包的名字 hello-0.0.1-SNAPSHOT.jar-->
    <description>Demo project for Spring Boot</description>
    <packaging>jar</packaging>  		  <!--打包方式jar/war-->
2. 打包

然后用maven打包。
在这里插入图片描述

[INFO] --- maven-jar-plugin:3.1.1:jar (default-jar) @ hello ---
[INFO] Building jar: D:\lillusory\MyProjects\hello\target\hello-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.1.3.RELEASE:repackage (repackage) @ hello ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  23.922 s
[INFO] Finished at: 2019-02-22T20:35:40+08:00
[INFO] ------------------------------------------------------------------------

日志中可以看到打出来的包在D:\lillusory\MyProjects\hello\target\hello-0.0.1-SNAPSHOT.jar

3. 测试

SpringBoot内置了一个Tomcat,可以直接java -jar jarName运行。

在这里插入图片描述

浏览器访问http://localhost:8080/hello出现hello illusoryCloud说明运行起来了。

这里的端口号是application.yml全局配置文件中配置的端口号。

2.3 war包

同时也可以打成war包然后用服务器上的Tomcat启动。

1.修改pom.xml
    <groupId>com.illusory</groupId>
    <artifactId>hello</artifactId>
    <version>0.0.1-SNAPSHOT</version>    <!--版本号-->
    <name>hello</name>   		 <!--打出来的包的名字 hello-0.0.1-SNAPSHOT.jar-->
    <description>Demo project for Spring Boot</description>
    <packaging>war</packaging>  		  <!--打包方式jar/war-->
<!--外置tomcat启动-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

maven中的 <scope>provided</scope>表示这个jar包在编译测试等地方是需要的,但是打包不会一起打包进去,这也避免了此类构件当部署到目标容器后产生包依赖冲突。由于SpringBoot内置了Tomcat所以这里需要重新配置一下,防止冲突。

2.改造启动类

SpringBoot 内置的Tomcat能认识自己的启动项,而外部tomcat是不认识的

所以需要修改启动类。即继承SpringBootServletInitializer类实现configure方法

/**
 * SpringBoot启动类
 * 打成war包时需要改造 继承SpringBootServletInitializer实现configure方法
 * 打jar包则不需要
 *
 * @author lixd
 */
@SpringBootApplication
public class HelloApplication extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
       //这里的HelloApplication是SpringBoot的启动类
        return builder.sources(HelloApplication.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(HelloApplication.class, args);
    }

}

3. 打包

和上面打包的方式一样的

[INFO] Packaging webapp
[INFO] Assembling webapp [hello] in [D:\lillusory\MyProjects\hello\target\hello-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Webapp assembled in [472 msecs]
[INFO] Building war: D:\lillusory\MyProjects\hello\target\hello-0.0.1-SNAPSHOT.war
[INFO] --- spring-boot-maven-plugin:2.1.3.RELEASE:repackage (repackage) @ hello ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:00 min
[INFO] Finished at: 2019-02-22T21:10:10+08:00
[INFO] ------------------------------------------------------------------------

可以看到打出来的war包在D:\lillusory\MyProjects\hello\target\hello-0.0.1-SNAPSHOT.war

4. 测试

先在电脑上测试一下(Windows环境下)

将war包复制到Tomcat的webapps文件夹下

然后找到bin目录下的startup.bat启动Tomcat,项目就会自动启动了。

浏览器访问http://localhost:8080/hello-0.0.1-SNAPSHOT/hello 出现hello illusoryCloud说明ok的。

这里hello-0.0.1-SNAPSHOT就是war包的名称,Tomcat启动时会自动解压war包然后启动项目。

这里的端口号和application.yml全局配置文件中配置的端口号没有关系,是Tomcat中配置的。

在Tomcat\conf\server.xml这个文件中,默认也是8080。

问题

我这里启动的时候出现了一个问题

Caused by: java.lang.NoClassDefFoundError: javax/el/ELManager

最后找到原因是tomcat提供的el-api.jar 和项目里面的el-api.jar冲突;

这时候你需要去找到自己电脑上用的el-api的版本,copy到tomcat的lib目录下,覆盖原来的jar包.

我的在IntelliJ IDEA 2018.3\lib\rt\jasper2.1\el-api.jar这个目录下

我看网上说是和Tomcat版本有关系,我这里是7.0.52

Tomcat日志

若是还有其他问题的话可以查看Tomcat日志。在tomcat\logs\catalina.2019-02-22.log这个文件中。

3. 部署

3.1 jar包

首先将文件上传到服务器上,服务器上有安装JDK8及以上的版本就可以直接运行。

Linux下JDK的安装及配置点这里

1. 前台运行
$ java -jar hello-0.0.1-SNAPSHOT.jar

但是这样运行的话是在前台运行,当前窗口关闭后就停止了,或者是运行时没法切出去执行其他任务.

2. 后台运行
$ nohup java -jar hello-0.0.1-SNAPSHOT.jar >temp.txt &

//nohup 意思是不挂断运行命令,当账户退出或终端关闭时,程序仍然运行
//这种方法会把日志文件输入到你指定的文件中(temp.txt)
//在哪个目录下运行的该日志文件就会在哪个目录下,没有指定具体文件则会自动创建(nohup.out)
//& 表示后台运行
3. 问题

执行以上命令后出现下面的提示

nohup: ignoring input and redirecting stderr to stdout
忽略输出 将错误输出重定向到标准输出

原因

Linux中0、1和2分别表示标准输入、标准输出和标准错误信息输出,可以用来指定需要重定向的标准输入或输出。在一般使用时,默认的是标准输出,即1。

例如:2>temp.txt 就是将错误信息写入temp.txt 标准输出还是显示在屏幕上。

另外,也可以实现0,1,2之间的重定向。2>&1:将错误信息重定向到标准输出。

Linux下还有一个特殊的文件/dev/null,它就像一个无底洞,所有重定向到它的信息都会消失得无影无踪。

如果想要正常输出和错误信息都不显示,则要把标准输出和标准错误都重定向到/dev/null, 例如:

1>/dev/null 2>/dev/null

解决办法

所以最后的命令就是

  nohup java -jar hello-0.0.1-SNAPSHOT.jar >temp.txt 2>&1&
[root@localhost software]# nohup java -jar hello-0.0.1-SNAPSHOT.jar >temp.txt 2>&1&
[1] 22804
// 成功启动 pid为22804
4. 测试

首先查看服务器的IP

[root@localhost software]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:8a:48:7d brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.111/24 brd 192.168.1.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe8a:487d/64 scope link 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:8e:d5:31 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:8e:d5:31 brd ff:ff:ff:ff:ff:ff

然后浏览器访问http://192.168.1.111:8080/hello出现hello illusoryCloud说明成功了。

记得关闭防火墙或者开放8080端口

5. 相关Linux命令
  • jobs命令和 fg命令
$ jobs
//那么就会列出所有后台执行的作业,并且每个作业前面都有个编号。
[root@localhost software]# jobs
[1]+  Running    nohup java -jar hello-0.0.1-SNAPSHOT.jar > temp.txt 2>&1 &
//如果想将某个作业调回前台控制,只需要 fg + 编号即可。
$ fg 1
  • 查看某端口占用的线程的pid
netstat -nlp |grep :8080
  • kill
kill pid

3.2 war包

war包运行和在windows上运行其实一样的,也是先将war包copy到Tomcat的webapps目录下,然后启动Tomcat,如果上面测试出现jar包冲突的话这里也需要替换。

Linux下Tomcat安装及配置点这里

启动Tomcat

进入Tomcat\bin目录执行./startup.sh即可

[root@localhost bin]# ./startup.sh 
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/jdk8
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

浏览器访问http://192.168.1.111:8080/hello-0.0.1-SNAPSHOT/hello出现hello world说明是没问题的。

4. 参考

https://blog.csdn.net/qq_22638399/article/details/81506448

https://blog.csdn.net/c1481118216/article/details/53010963

https://blog.csdn.net/qq_14853889/article/details/80026885

SpringBoot项目部署到服务器 阅读详情

相关推荐

IDEA搭建Spring-Boot之 Hello World

今天和大家分享如何使用SpringBoot在浏览器中显示Hello World,这是学习SpringBoot的第一步,也是我第一次装模作样地写写文章,嘻嘻~不足之处还请大家多多指教…接下来讲解详细过程: 环境准备: 1)JDK 1.8.0_131(版本建议1.7及以上) 2) Maven 3.6.0 3)IDEA 2019.1.3(也可使用Eclipse) 4)SpringBoot 1.5.9.R...

wangjianqi213的博客 441

使用IDEA打包发布SpringBoot并部署到云服务器

使用IDEA打包发布SpringBoot并部署到云服务器的简单有效方法

InetGeek的博客 5817

5.1 滑模控制(SMC)及其改进

本文系统阐述了滑模控制(SMC)的基本原理及其在永磁同步电机(PMSM)控制系统中的应用。首先介绍了滑模控制的核心思想,包括滑模面设计和不连续控制律,其强鲁棒性使其在电机控制领域得到广泛应用。其次分析了SMC在PMSM速度控制器和无位置传感器观测器中的具体实现方案。重点探讨了SMC固有的抖振问题,详细比较了边界层法、高阶滑模和自适应方法等多种改进策略的优缺点。最后指出改进SMC的研究趋势是多种策略的融合应用,如自适应高阶滑模等,以在保持鲁棒性的同时有效抑制抖振。

技术工作者 1455

Idea对SpringBoot项目进行打包发布

前段时间,在写的项目需要打包发布,放到Tomcat上面运行,结果本以为是很简单的事情,还是浪费了好一会...,本着面向google编程的思想,查了一些资料,迟迟无法解决。后面发现,SpringBoot项目打包和其他项目是不同的,需要对入口启动类进行一些调整。这里记录一下使用idea对SpringBoot项目进行打包的过程。 以打成war包为例 因为是SpringBoot项目,需要对启动类进行一......

Java 6947

用豆包+Skill从零制作AI漫剧:分镜、画面、配音到成片全流程

AI漫剧作为一种新兴内容形态,结合AI绘画与AI视频生成技术,正在改变短视频创作方式。其核心原理是利用提示词工程,将创意转化为结构化分镜脚本,再通过豆包等AI助手的Skill能力,将重复的脚本生成和分镜拆解流程固化为可复用的指令模板,从而大幅降低从构思到成品的生产门槛。这种模式无需剧组、演员和实景拍摄,让个人创作者也能借助图像生成、TTS配音与剪辑合成工具,批量化地生产剧情短片,适用于短视频平台连载、商业定制与个人IP打造。围绕豆包+Skill这条主线,从选题、剧本写作、分镜表设计,到画面提示词生成、视频片

weixin_29048309的博客 1685

SPSS实战:5步搞定多指标联合诊断的ROC曲线分析(附Logistic回归教程)

本文详细介绍了如何使用SPSS软件进行多指标联合诊断的ROC曲线分析。通过5个实战步骤,从数据准备、二元Logistic回归建模生成综合预测概率,到绘制并比较单指标与联合模型的ROC曲线,帮助临床研究者有效整合多个诊断指标,提升模型判别能力(AUC),实现诊断效能的优化。

mqtt6iot的博客 1429

IntelliJ IDEA 打包 SpringBoot 项目并部署到 Linux 服务器

IntelliJ IDEA 打包 SpringBoot 项目并部署到 Linux 服务器一、IDEA 打包项目二、上传 jar 包到 Linux 服务器三、部署 Linux 运行环境,执行 jar 文件 一、IDEA 打包项目 1.在 IDEA 上 File—>Setting—>Project Structure 选择 Artifacts ,右上角加号添加—>jar 2.选择项...

weixin_42428899的博客 1395

深入解析iDP3的Learning模块:从数据集构建到3D动作预测的代码实现

本文深入解析iDP3框架的Learning模块,从数据集构建到3D动作预测的完整代码实现。通过扩散模型实现视觉输入到动作序列的端到端预测,详细介绍数据采集、增强策略、模型架构及训练技巧,帮助开发者掌握3D动作预测策略的核心技术。

k0l1m2n3o的博客 318

使用idea打包spring boot项目,并部署到Linux服务器。

打包: springboot大多数是打jar包,也可以打war包,但是官方文档推荐的是打包成JAR,作为一个web应用,为什么会推荐打包成JAR,这是因为SpringBoot内集成了Tomcat服务器,当你启动SpringBoot应用的时候,内置的Tomcat服务器就 会启动,加载web应用。 第一步 执行clean,清除掉之前的包,第二步 执行install 生成新包。 注意观察控制台日志 ,...

u010797364的博客 1518

关于使用CMT2300A FIFO缓存区间设置为64Byte的问题

帮助你解决在使用CMT2300A 时遇到的各种问题,若有需要,请及时与我交流

teleger的博客 1435

数据库实验报告--MySQL

数据库完整版报告--MySQL 包括数据库创建、表的创建、视图以及授权和触发器的创建等内容,全是精华!看完点赞加收藏O(∩_∩)O~。

Mortalz7 4927

linux部署jar项目报错_使用IDEA将SpringBoot项目打包成Jar包并部署到Linux服务器步骤及注意事项...

一、将SpringBoot项目打成Jar包:1、首先要保证SpringBoot项目能正常启动2、在项目的pom.xml文件中增加配置信息,具体配置如下:com.boncenergy0.0.1-SNAPSHOTjarenergymanagementsrc/main/resourcesfalseapplication*.propertiesconf/dev/*src/main/resources/co...

weixin_28750421的博客 628

LMK04828时钟芯片配置实战:从原理到调试的完整指南

锁相环(PLL)是时钟生成与分配的核心技术,通过相位反馈控制实现频率合成与抖动滤除。其原理基于鉴相器、环路滤波器和压控振荡器的协同工作,能够将低质量的参考时钟转换为高稳定、低抖动的输出信号,为高速数据转换、通信系统提供精准时序基础。在JESD204B/C等高速接口应用中,时钟的相位噪声和同步精度直接决定了系统性能上限。本文以TI高性能时钟芯片LMK04828为例,深入解析其双PLL架构与小数分频合成原理,并聚焦于SYSREF信号生成与同步配置这一关键实践,提供从频率规划、环路参数设计到SPI寄存器配置的全流

weixin_33747129的博客 459

使用IDEA将SpringBoot项目打包成Jar包并部署到Linux服务器

一、将SpringBoot项目打成Jar包: 1、首先要保证SpringBoot项目能正常启动 2、在项目的pom.xml文件中增加配置信息<bulid></build>,具体配置如下: <groupId>com.bonc</groupId> <artifactId>energy</artifactId> <ve...

qq_27346503的博客 1583

关于Sybase ASE数据库的license以及试用版过期的问题的解决方案

当用户从Sybase官网上下载了ASE15.0.2以后,如果选择了安装Express Edition或者Developer Edition,基本上不会碰到什么问题,除了有些功能受限以下。 但大多数可能选择了Enterprise Edition for Evaluation类型,即企业版试用。都会碰到这样的问题,即一个月以后,license过期,无法启动server。于是很郁闷,可能大部分人,会选...

iihero@CSDN 792

深度学习工具包 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")

怎么在Linux上部署运行SpringBoot+maven分模块(含jsp) 的war项目??

项目:SpringBoot+maven分模块(注意: 这是创建了项目的时候有选中了maven) 首先要在IDEA进行打包, 然后才在Linux进行部署运行 在此之前有两个需要注意的地方,也就是父项目(goods_parent)和web项目(goods_web)的Pom.xml 步骤一:查看父项目Pom.xml中是否有 <build>相应的打包依赖,如果有的话删除,否则可能会报错,导致打包失败 如:我的Pom.xml 是没有build的 <?xml ve...

每天进步一点点 596

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

使用IDEA将SpringBoot项目打包成Jar包并部署到Linux服务器步骤及注意事项

一、将SpringBoot项目打成Jar包: 1、首先要保证SpringBoot项目能正常启动 2、在项目的pom.xml文件中增加配置信息<bulid></build>,具体配置如下: <groupId>com.bonc</groupId> <artifactId>energy</artifactId> <ve...

xiaobanv1的专栏 1万+

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

IntelliJ IDEA开发SpringBoot SpringCoud项目,一键生成docker镜像推送私服、简单部署并发布

IntelliJ IDEA开发SpringBoot SpringCoud项目,使用jib-maven-plugin 制作docker镜像并推送到么服、使用alibaba cloud toolkit 执行远程项目 IntelliJ IDEA安装插件--Cloud Toolkit 使用IntelliJ IDEA部署应用到Linux服务器 https://help.aliyun.com/document_detail/108590.html?spm=a2c4g.11186623.6.576.3c584c3fA

mxskymx的专栏 449

在IDEA中如何将Spring boot项目打包成可执行的jar包并发布到linux服务器

在IDEA中如何将Spring boot项目打包成可执行的jar包并发布到linux服务器

AQIANG博客 8万+

记一次Linux安装Maven、Git并拉取SpringBoot代码打包

Linux安装Git、Maven工具,一键脚本打包springboot项目成jar,idea远程运行。

qq_39853669的博客 1417

idea重新打包SpringBoot项目部署到Linux服务器

idea重新打包SpringBoot项目部署到Linux服务器idea重新打包关掉原来进程替换打包的包重新运行jar包 idea重新打包 在idea工具栏选择build——》Build Artifacts 。 会在界面弹出Build Artifact的小框,然后选择Rebuild(首次可选择Build)。 在xxx项目目录下——》out——》artifacts——》xxx_jar——》xxx.jar,找到打包好的jar包,注意看jar包的生成时间,以免没有重新打包。   关掉原来进程

海风是什么风 686

一文带你快速了解如何在Linux上部署项目

一、手工部署项目 二、通过Shell脚本自动部署项目

HHX_01的博客 7309

SpringBoot项目部署Linux服务器以及idea远程debug

服务器必须有与本地开发相同的java环境。

m0_52067452的博客 553

Mac向云服务器部署SpringBoot项目

Mac向云服务器部署SpringBoot项目检查Java环境把项目打包scp实现Mac向Linux上传jar包运行项目 如果jdk没有安装的请参考我的上一篇博客 Linux便捷安装JDK 检查Java环境 java -version 把项目打包 已IDEA为例,点击package就可以将项目进行打包 打包之后target目录下就有一个jar包 scp实现Mac向Linux上传jar包 scp...

qq_41541368的博客 1164

springboot项目部署到服务器(jar方式)

Springboot 部署会采用两种方式:全部打包成一个jar,或者打包成一个war,我们这里只阐述jar方式。

god_hao12的博客 819

idea将springboot项目打jar包发布到linux中,部署并运行

我用的是jdk1.8 mysql8 一、准备工作 1、linux安装jdk 2、linux安装mysql 3、linux数据库的创建 备份本地数据库: 右键数据库–>转储SQL文件–>结构和数据 在连接linux数据库中运行刚刚保存的文件 4、更改连接mysql的代码 这里要注意linux的主机和登录用户、密码 二、项目打包上传 1、右击maven,找到项目下的Lifecycle下的package,双击package 打包成功 找到项目目录下的target,能找到我们刚刚打包的jar包

qq_46344415的博客 613
上一篇: volatile关键字在单例模式(双重校验锁)中的作用
下一篇: ReentrantLock源码分析
探索云原生
博客等级 码龄9年 730粉丝 131原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址