Java教程

idea通过maven打包(三)

本文主要是介绍idea通过maven打包(三),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

前言

现在开发的项目多为mavne管理。熟悉idea通过maven打包流程及常见问题解决。

一、打包流程

1.1idea通过maven打包项目spring-boot项目

 

参看链接:

1.2配置文件

1.3本地通过java -jar命令启动

1.3.1 java命令执行jar包带环境变量

java -jar reins-monitor-backend-1.0.jar --jasypt.encryptor.password=asd
或
java -Djasypt.encryptor.password=asd -jar reins-monitor-backend-1.0.jar 

参看链接:https://blog.csdn.net/weixin_39720807/article/details/114355543

1.3.2 spring-boot项目的jar文件读取配置文件的方式

二、常见问题

2.1 报错一

SpringBoot启动时报org.springframework.context.annotation.ConflictingBeanDefinitionException
解决方法参看链接: https://blog.csdn.net/u013360850/article/details/77622629/

这是因为在应用中使用到了多个该类的对象,而该类的对象通过注解的方式注入到应用中,在注入的过程中因为对象的名称重复导致了该异常 
通过指定注入对象的名称可以解决这个问题。

参看链接:https://blog.csdn.net/u013360850/article/details/77622629/

我报这个错的原因是因为在打包前,没有编译,还是编译有误。。。导致生成一个重复的class文件,重新编译后,打包,问题解决。

com.picc.reins.hdrdomain.domain.zrj.facade.ZrjDao
com.picc.reins.hdrdomain.domain.zrj.repository.facade.ZrjDao

报错信息:

[2021-08-25 17:26:41.610] [main] [INFO ] [TID: N/A] [LAPTOP-MHHBQEIO/11.204.117.183] [] [c.u.j.c.EnableEncryptablePropertiesConfiguration] [] [] [] [Bootstraping jasypt-string-boot auto configuration in context: application-1]
[2021-08-25 17:26:41.611] [main] [INFO ] [TID: N/A] [LAPTOP-MHHBQEIO/11.204.117.183] [] [com.picc.reins.ReinsMonitorBackend] [] [] [] [No active profile set, falling back to default profiles: default]
[2021-08-25 17:26:41.627] [main] [INFO ] [TID: N/A] [LAPTOP-MHHBQEIO/11.204.117.183] [] [o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext] [] [] [] [Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@4e41089d: startup date [Wed Aug 25 17:26:41 CST 2021]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@649d209a]
[2021-08-25 17:26:42.710] [main] [INFO ] [TID: N/A] [LAPTOP-MHHBQEIO/11.204.117.183] [] [o.s.d.r.config.RepositoryConfigurationDelegate] [] [] [] [Multiple Spring Data modules found, entering strict repository configuration mode!]
[2021-08-25 17:26:42.740] [main] [INFO ] [TID: N/A] [LAPTOP-MHHBQEIO/11.204.117.183] [] [o.s.d.r.config.RepositoryConfigurationDelegate] [] [] [] [Multiple Spring Data modules found, entering strict repository configuration mode!]
[2021-08-25 17:26:43.088] [main] [ERROR] [TID: N/A] [LAPTOP-MHHBQEIO/11.204.117.183] [] [org.springframework.boot.SpringApplication] [] [] [] [Application run failed]
org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'zrjDao' for bean class [com.picc.reins.hdrdomain.domain.zrj.facade.ZrjDao] conflicts with existing, non-compatible bean definition of same name and class [com.picc.reins.hdrdomain.domain.zrj.repository.facade.ZrjDao]
        at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.checkCandidate(ClassPathBeanDefinitionScanner.java:348)
        at org.mybatis.spring.mapper.ClassPathMapperScanner.checkCandidate(ClassPathMapperScanner.java:310)
        at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:286)
        at org.mybatis.spring.mapper.ClassPathMapperScanner.doScan(ClassPathMapperScanner.java:204)
        at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.scan(ClassPathBeanDefinitionScanner.java:253)
        at org.mybatis.spring.mapper.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:375)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:271)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:121)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230)
        at com.picc.reins.ReinsMonitorBackend.main(ReinsMonitorBackend.java:22)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
[2021-08-25 17:26:43.089] [main] [INFO ] [TID: N/A] [LAPTOP-MHHBQEIO/11.204.117.183] [] 
[o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext] [] [] [] [Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@4e41089d: 
startup date [Wed Aug 25 17:26:41 CST 2021]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@649d209a]
View Code

2.2报错二

报错信息:

[2021-08-25 17:52:13.782] [main] [INFO ] [TID: N/A] [LAPTOP-MHHBQEIO/11.204.117.183] [] [c.u.j.encryptor.DefaultLazyEncryptor] [] [] [] [Encryptor config not found for property jasypt.encryptor.saltGeneratorClassname, using default value: org.jasypt.salt.RandomSaltGenerator]
[2021-08-25 17:52:13.784] [main] [INFO ] [TID: N/A] [LAPTOP-MHHBQEIO/11.204.117.183] [] [c.u.j.encryptor.DefaultLazyEncryptor] [] [] [] [Encryptor config not found for property jasypt.encryptor.stringOutputType, using default value: base64]
[2021-08-25 17:52:14.233] [main] [ERROR] [TID: N/A] [LAPTOP-MHHBQEIO/11.204.117.183] [] [com.alibaba.druid.pool.DruidDataSource] [] [] [] [init datasource error, url: jdbc:informix-sqli://10.133.200.14:9032/newreinsdb:informixserver=newreins_hdr;NEWCODESET=gbk,8859-1,819]
java.sql.SQLException: com.informix.asf.IfxASFException: Code-set conversion function failed due to illegal sequence or invalid value.
        at com.informix.jdbc.IfxSqliConnect.<init>(IfxSqliConnect.java:1664)
        at com.informix.jdbc.IfxDriver.connect(IfxDriver.java:200)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1643)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1709)
        at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:932)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
View Code

原因:jar包存放目录含有中文。

三、延伸

这篇关于idea通过maven打包(三)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!