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

网络营销对于个人而言有什么作用深圳做网站优化

网络营销对于个人而言有什么作用,深圳做网站优化,wordpress首页默认中文,制作网站的全过程Tomcat转SpringBoot、tomcat升级到springboot、springmvc改造springboot 起因#xff1a;我接手tomcat-springmvc-hibernate项目#xff0c;使用tomcat时问题不大。自从信创开始#xff0c;部分市场使用国产中间件#xff0c;例如第一次听说的宝兰德、东方通#xff0c;还…Tomcat转SpringBoot、tomcat升级到springboot、springmvc改造springboot 起因我接手tomcat-springmvc-hibernate项目使用tomcat时问题不大。自从信创开始部分市场使用国产中间件例如第一次听说的宝兰德、东方通还有一些市场使用weblogic、WebSphere特别是商用中间件难以满足本地运行并编写部署文档只能靠市场自行摸搜适配。 那咋办我直接把tomcat应用直接改造成springboot应用不就完事了省去了中间件、中间商赚差价、虽然springboot底层用tomcat运行web但没有了宝兰德、东方通的适配报错。 原项目tomcat warspring5springmvchibernatemysql 改造后springbootspringbootwebhibernatemysql 添加依赖 第一步是添加springboot依赖 !-- 打包类型为jar -- packagingjar/packaging propertiesproject.build.sourceEncodingUTF-8/project.build.sourceEncodingproject.reporting.outputEncodingUTF-8/project.reporting.outputEncoding!-- spring的版本应该与springboot内的spring版本一致 --spring.version5.3.30/spring.versionspringboot.version2.7.18/springboot.versionhibernate.version5.6.15.Final/hibernate.version /propertiesdependencies!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot/artifactIdversion${springboot.version}/version/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactIdversion${springboot.version}/version/dependency!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-freemarker --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-freemarker/artifactIdversion${springboot.version}/version/dependency// 项目其他依赖 /dependenciesplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactIdversion${springboot.version}/versionconfigurationexcludesexcludegroupIdorg.projectlombok/groupIdartifactIdlombok/artifactId/exclude/excludesmainClassapp.MyApplication/mainClass/configuration /plugin原来是spring5.3.x对应springboot2.7.x 转化web.xml 1、编写一个MyApplication SpringBootApplication(exclude {RedisAutoConfiguration.class, SpringDataWebAutoConfiguration.class},scanBasePackages {app, cn.com.xxxxx} ) ImportResource({classpath:spring.xml, classpath:spring-ds.xml, classpath:spring-validator.xml}) Slf4j public class MyApplication {public static void main(String[] args) {ConfigurableApplicationContext context SpringApplication.run(MyApplication.class, args);String port context.getEnvironment().getProperty(server.port);if (portnull)port8080;log.info(web: {}, http://localhost: port);} }特别注意使用 ImportResource 导入原有的xml配置还有包扫描路径 scanBasePackagesMyApplication 所放的位置有讲究通常放到包的根目录下 2、创建一个 src/main/resources/application.properties spring.main.allow-bean-definition-overridingtrue spring.main.allow-circular-referencestrue spring.jpa.open-in-viewfalse server.servlet.context-path/app允许bean循序、bean重写、web访问上下文路径 3、将web.xml中的 filter/Listener转化为bean //使用RegistrationBean方式注入ListenerBeanpublic ServletListenerRegistrationBean servletListenerRegistrationBean() {AppSessionListener myListener new AppSessionListener();//创建原生的Listener对象return new ServletListenerRegistrationBean(myListener);}//使用RegistrationBean方式注入ListenerBeanpublic ServletListenerRegistrationBean servletListenerRegistrationBean2() {AppServletContextListener myListener new AppServletContextListener();//创建原生的Listener对象return new ServletListenerRegistrationBean(myListener);}其他的就不多赘述 静态文件转发 tomcat应用的静态文件通常放在app/WebContent下 例如app/WebContent/js/app.js我们需要将它挂载到静态路径下 /*** author lingkang* created by 2023/12/8*/ Slf4j Configuration public class StaticSourceConfig implements WebMvcConfigurer {/*** 部署本地资源到url** param registry*/Overridepublic void addResourceHandlers(ResourceHandlerRegistry registry) {File file new File(System.getProperty(user.dir) File.separator WebContent);String path file.getAbsolutePath();if (!path.endsWith(/))pathpathFile.separator;log.info(静态文件映射路径{}, path);registry.addResourceHandler(/**).addResourceLocations(file: path);} }打包 基于上面的基本告一段落了在没有移动前端资源的情况同时我们的老项目有那么多xml配置不可能将它打包到jar里否则不符合修改迁移。这时候就要用到maven-assembly-plugin插件了pom.xml配置如下 plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-compiler-plugin/artifactIdversion3.5.1/versionconfigurationsource1.8/sourcetarget1.8/targetencodingUTF-8/encodingcompilerArgsarg-parameters/argarg-extdirs/argarg${project.basedir}/WebContent/WEB-INF/lib/arg/compilerArgs/configuration /plugin plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-assembly-plugin/artifactIdversion3.6.0/versionconfigurationappendAssemblyIdfalse/appendAssemblyIddescriptorRefsdescriptorRefjar-with-dependencies/descriptorRef/descriptorRefsarchive!-- 此处要改成自己的程序入口即 main 函数类 --manifestmainClassapp.MyApplication/mainClass/manifest/archivedescriptors!--assembly配置文件路径注意需要在项目中新建文件package.xml--descriptor${project.basedir}/src/main/resources/package/package.xml/descriptor/descriptors/configurationexecutionsexecutionidmake-assembly/idphasepackage/phasegoalsgoalsingle/goal/goals/execution/executions /pluginsrc/main/resources/package/package.xml配置如下 ?xml version1.0 encodingUTF-8? assembly xmlnshttp://maven.apache.org/ASSEMBLY/2.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd!--assembly 打包配置更多配置可参考官方文档http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html--idrelease/id!--设置打包格式可同时设置多种格式常用格式有dir、zip、tar、tar.gzdir 格式便于在本地测试打包结果zip 格式便于 windows 系统下解压运行tar、tar.gz 格式便于 linux 系统下解压运行--formatsformatdir/format!--formatzip/format--!-- formattar.gz/format --/formats!-- 打 zip 设置为 true 时会在 zip 包中生成一个根目录打 dir 时设置为 false 少层目录 --!--includeBaseDirectorytrue/includeBaseDirectory--fileSets!-- src/main/resources 全部 copy 到 config 目录下 --fileSetdirectory${basedir}/src/main/resources/directoryoutputDirectoryconfig/outputDirectoryincludes!--包含那些依赖--/includes/fileSet!-- 项目根下面的脚本文件 copy 到根目录下 --fileSetdirectory${basedir}/src/main/resources/package/directoryoutputDirectory/outputDirectory!-- 脚本文件在 linux 下的权限设为 755无需 chmod 可直接运行 --fileMode755/fileModelineEndingunix/lineEndingincludesinclude*.sh/include/includes/fileSetfileSetdirectory${basedir}/WebContent/WEB-INF/lib/directoryoutputDirectorylib/outputDirectoryincludes!--包含那些依赖--include*.jar/include/includes/fileSet!-- 静态资源 awb.operations.config.StaticSourceConfig --fileSetdirectory${basedir}/WebContent/directoryoutputDirectoryWebContent/outputDirectoryincludes!--包含那些依赖--includecompressor/**/includeincludeconf/**/includeincludedependence/**/includeincludeelementui/**/includeincludefonts/**/includeincludeicons/**/includeincludeimage/**/includeincludeimg/**/includeincludemodule/**/includeincludenodejs/**/includeincludescript/**/includeinclude*.js/includeinclude*.html/includeinclude*.css/includeinclude*.json/include/includes/fileSet/fileSets!-- 依赖的 jar 包 copy 到 lib 目录下 --dependencySetsdependencySetoutputDirectorylib/outputDirectory/dependencySet/dependencySets/assembly/src/main/resources/package/start.sh运行内容如下 #!/bin/bash # ---------------------------------------------------------------------- # # 使用说明 # 1: 该脚本使用前需要首先修改 MAIN_CLASS 值使其指向实际的启动类 # # 2使用命令行 ./start.sh start | stop | restart 可启动/关闭/重启项目 # # # 3: JAVA_OPTS 可传入标准的 java 命令行参数例如 -Xms256m -Xmx1024m 这类常用参数 # # 4: 函数 start() 给出了 4 种启动项目的命令行根据注释中的提示自行选择合适的方式 # # ----------------------------------------------------------------------# 启动入口类该脚本文件用于别的项目时要改这里 MAIN_CLASSapp.MyApplicationif [[ $MAIN_CLASS app.MyApplication ]]; thenecho 请先修改 MAIN_CLASS 的值为你自己项目启动Class然后再执行此脚本。exit 0 fiCOMMAND$1if [[ $COMMAND ! start ]] [[ $COMMAND ! stop ]] [[ $COMMAND ! restart ]]; then # echo Usage: $0 start | stop | restart , 例如 sh start.sh start / sh start.sh stop # exit 0 COMMANDstart fi# Java 命令行参数根据需要开启下面的配置改成自己需要的注意等号前后不能有空格 JAVA_OPTS-Xms512m -Xmx2048m # JAVA_OPTS-Dserver.port80 # 生成 class path 值 APP_BASE_PATH$(cd dirname $0; pwd) CP${APP_BASE_PATH}/config:${APP_BASE_PATH}/lib/*function start() {# 运行为后台进程并在控制台输出信息#java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} # 运行为后台进程并且不在控制台输出信息# nohup java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} /dev/null 21 # 运行为后台进程并且将信息输出到 output.out 文件nohup java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} nohup.out # 运行为非后台进程多用于开发阶段快捷键 ctrl c 可停止服务# java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} }function stop() {# 支持集群部署kill pgrep -f ${APP_BASE_PATH} 2/dev/null# kill 命令不使用 -9 参数时会回调 onStop() 方法确定不需要此回调建议使用 -9 参数# kill pgrep -f ${MAIN_CLASS} 2/dev/null# 以下代码与上述代码等价# kill $(pgrep -f ${MAIN_CLASS}) 2/dev/null }if [[ $COMMAND start ]]; thenstart elif [[ $COMMAND stop ]]; thenstop elsestopstart fi这时候就能执行打包了 或者 mvn package效果如下 然后将整个路面打包成zip传到服务器运行即可
http://www.hkea.cn/news/14451028/

相关文章:

  • 公司名称logo设计江门网站优化快速排名
  • 社区平安建设基层网站泰州网站建设电话
  • 如何创建游戏网站网页优化方案
  • 如何搭建公司内部网站网站建设淘宝客模板下载
  • 上海比较好的网站建设公司停止wordpress
  • 有网站开发专业吗网站建设网站网站建设网站
  • 电商网站建设的目标做网站的版式会侵权吗
  • wordpress 4.1 主题seo推广公司网站模板
  • 建设环保网站查询系统郑州注册公司流程及费用
  • 怎么健手机网站阿里云网站怎么备案域名解析
  • 淘宝上网站建设为啥这么便宜wordpress防止文章被采集
  • 做logo赚钱的网站公众号怎么建立
  • 佛山门户网站建设公司江西最新新闻事件
  • 什么是网站的功能模块工程监理行业为什么做网站
  • 校园文化网站建设莱芜在线论坛莱芜话题西关规划图
  • 集团网站推广哈尔滨一恒建设
  • 网站详情页链接怎么做wordpress忘记密码邮件收不到
  • 昆明seo博客南网站建设网站页面设计分析
  • 自适应 网站开发二次开发招聘
  • 义乌网站建设工作室高端网站制作公
  • 深圳高端做网站东莞便宜做网站
  • 深夜小网站网站建设流程 费用
  • 毕业设计论文网站开发需要多少wordpress 屏蔽搜索引擎
  • 浙江做网站找谁免费海外网站建设
  • 青岛网站搜索排名西安网站建设怎样
  • 建设团购网站费用天津seo推广方法
  • 关于网站制作报价网站开发具备的相关知识
  • 建设网站服务器是什么邢台公司做网站多少钱
  • 网站建设是怎么赚钱的系统开发是什么意思
  • 我的网站模板下载不了网站怎么加链接