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

上海沪港建设咨询有限公司网站竞价托管资讯

上海沪港建设咨询有限公司网站,竞价托管资讯,莱芜泉网站建设,苏州做网站推广的公司背景说明: 有两个SpringBoot工程(代号A:标准产品,代号B:产品定制) 代号B工程是一个空壳子工程,包结构如下图:分为接口包和实现包两个 在代号A工程中配置好 ComponentScan &#xf…

背景说明:

有两个SpringBoot工程(代号A:标准产品,代号B:产品定制)

代号B工程是一个空壳子工程,包结构如下图:分为接口包和实现包两个

在代号A工程中配置好 @ComponentScan ,并在pom.xml中引入实现包后,发现代码A工程在启动的时候并不会去扫描代号B的实现包,仅仅是扫描接口包(因为实现包需要依赖接口包,故在引入实现包后接口包也会被引入),而且接口包中接口虽在实现包中已实现,但是在包扫描中仍然会被认为是 Ignored because not a concrete top-level class

这里代码有点问题,Java类名字重复

感觉应该和打包出来之后的文件路径有关系,可以从如何扫描到包的方式入手,其实就是读取jar包文件

没明白为啥 

--------------------------------------分割线,下面是SpringBoot打包东西-------------------------------------------

SpringBoot项目打包有关BOOT-INF文件夹问题

1、.spring-boot maven打包,一般pom.xml文件里会加

<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

这样打的jar里会多一个目录BOOT-INF。

2.引起问题,程序包不存在。

3.解决办法,如果A子模块包依赖了B子模块包,在B子模块的pom文件,加入

<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><!--如果添加次配置,jar包不会有任何依赖--><skip>true</skip></configuration>
</plugin>

或者将B子模块的pom打包改成

    <plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId></plugin><!--  添加编译插件 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.5.1</version><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin></plugins>

--------------springboot打包部署-------------------------------------------------------------------------------

一、打成jar部署

利用springboot的插件打包

<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

 如果要引入本地jar配置,如下图

pom.xml配置如下

<dependency><groupId>eis_protobuf</groupId><artifactId>eis_protobuf</artifactId><version>1.0</version><scope>system</scope><systemPath>${project.basedir}/lib/eis_protobuf.jar</systemPath></dependency>

springboot-maven-plugin打包的第一级目录为Boot-INF,如果不做任何配置,直接mvn clean package会发现无法把本地的jar打进Boot-INF中,则此时要做如下配置 

方法一

在pom.xml的resources节点添加如下内容

<resource><directory>lib</directory><targetPath>BOOT-INF/lib/</targetPath><includes><include>**/*.jar</include></includes>
</resource>

 ps: 如果遇到一些外部配置文件比如mybatis的mapper文件或者activiti生成器的json文件,则也要把相应的文件打进resources中,否则项目启动会因找不到配置文件,而报错,配置文件如下

<resource><directory>${basedir}/src/main/java</directory><filtering>false</filtering><includes><include>**/*.xml</include><include>**/*.properties</include></includes></resource><resource><directory>${basedir}/src/main/resources</directory><filtering>true</filtering><excludes><exclude>templates/**</exclude><exclude>static/**</exclude></excludes><includes><include>**/*.xml</include><include>**/*.yml</include><include>**/*.yaml</include><include>**/*.properties</include><include>**/*.key</include><include>**/*.des</include><include>**/*.template</include><include>**/*.json</include></includes></resource>

方法二

在spring-boot-maven-plugin插件中设置includeSystemScope参数

<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><includeSystemScope>true</includeSystemScope></configuration></plugin></plugins>
</build>

二 把sprinboot项目达成war包部署到外部tomcat

1、修改打包方式,把jar改成war,改成如下配置

<packaging>war</packaging>

2、引入tomcat依赖jar,scope范围为provided,并排除springboot内嵌的tomcat依赖jar,其实不排除也没关系,不影响项目运行

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId><scope>provided</scope>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><exclusions><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId></exclusion></exclusions>
</dependency>

3、修改打包插件,不使用spring-boot-maven-plugin插件打包,因为这个打包插件会把jar打包在Boot-INF目录下导致别的项目引用时引用不到,此时改用maven-war-plugin打包,具体配置如下

<plugin><artifactId>maven-compiler-plugin</artifactId><version>2.3.2</version><configuration><source>1.8</source><target>1.8</target></configuration>
</plugin>

4、修改启动类,启动类继承SpringBootServletInitializer,并重写configure方法

@SpringBootApplicationpublic class SpringbootDemo extends SpringBootServletInitializer {@Overrideprotected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {return builder.sources(SpringbootDemo.class);}public static void main(String[] args) {new SpringApplicationBuilder(SpringbootDemo.class).web(true).run(args);}
}

 

参考资料:

1、springboot打包部署的那些事-腾讯云开发者社区-腾讯云

2、spring-boot子模块打包去掉BOOT-INF文件夹_spring-boot项目打包去掉boot-inf文件夹-CSDN博客

http://www.dtcms.com/wzjs/158097.html

相关文章:

  • 高校档案室网站建设全国疫情的最新数据
  • 阿里云网站备案网站建设方案书高端网站建设哪个好
  • 公司网站管理维护自己怎么做网址开网站
  • 网站开发报价nba排名赛程
  • 可不可以用帝国cms做企业网站线上购买链接
  • 新手做网站宁波免费seo排名优化
  • 长春网络公司宣传seo优化就业前景
  • dnf网站上怎么做商人网站维护需要多长时间
  • wordpress4 sqlite标题优化seo
  • 如何为网站做优化如何进行网站性能优化
  • 创办网站需要什么网络营销运营推广
  • 深圳做网站网络销售怎么找客户
  • 数字化文化馆网站建设网络推广公司运作
  • 怎么做网站开发微信小程序怎么开通
  • 网站开发后期要解决的问题seo优化技术培训中心
  • 沂水住房与城乡建设局网站深圳互联网公司排行榜
  • 主流的网页设计软件seo搜索铺文章
  • 开网络公司做网站挣钱吗客户引流推广方案
  • 用dw可以做网站吗网络营销有哪些内容
  • 做网站标题代码营销百度app下载手机版
  • 沭阳网站建设招聘培训机构网站制作
  • 织梦网站写软文一篇多少钱合适
  • 通州网站建设公司深圳网络营销平台
  • 哪个网站用织梦做的网站推广优化之八大方法
  • 网站建设标题怎么写百度搜索引擎介绍
  • 建设工程信息服务平台新网站windows优化大师官方网站
  • 军事网站模板下载友情链接软件
  • 阿里云服务器创建网站吗网站排名软件推荐
  • 抖音代运营ppt网站优化平台
  • 网站建好后新闻发布平台