折腾:
【未解决】Mac本地测试远程服务器中taos报错:java.lang.UnsatisfiedLinkError no taos in java.library.path
期间,先去弄,把Mac的本地的SpringBoot的Java后端服务,上传,部署到远程服务器CentOS7中。
此处对于Java部署一无所知。所以需要慢慢弄。
java spring boot deploy to centos 7
然后之前知道的:
1 2 | mvn clean package java -jar target /xxx-0 .0.1-SNAPSHOT.jar |
试试解压jar后有哪些
不过要先去
1 | mvn clean package |
打包。
但是发现必须改回mysql的配置:
1 2 3 | spring.datasource.url = jdbc:mysql: / / ${MYSQL_HOST:localhost}: 3306 / xxx?useUnicode = yes&characterEncoding = UTF - 8 spring.datasource.username = xxx spring.datasource.password = xxx |
才能继续重新打包。
且还要先启动mysql
1 | /usr/local/mysql/support-files/mysql .server start |
才可以。
生成jar了。去解压试试
1 | jar -xf xxx-1.0.0-SNAPSHOT.jar |
输出空的。
好像多出一个文件夹。
但是没注意是哪个。
看到:
1 | java org.springframework.boot.loader.JarLauncher |
回去一看,好像是org文件夹,果然找到了这个:

试试:
1 | java org.springframework.boot.loader.JarLauncher |
结果还报错了:
【未解决】Java的SpringBoot的jar解压后用JarLauncher启动报错:src/main/resources/log4j2.xml No such file or directory
去加上:
1 2 3 | < configuration > < executable >true</ executable > </ configuration > |
变成:
1 2 3 4 5 6 7 8 9 10 11 | < build > < plugins > < plugin > < groupId >org.springframework.boot</ groupId > < artifactId >spring-boot-maven-plugin</ artifactId > < configuration > < executable >true</ executable > </ configuration > </ plugin > </ plugins > </ build > |

去打包
1 2 3 4 | mart_electric_server master ● mvn clean package >> mvn_package_3.log crifan@licrifandeMacBook-Pro ~ /dev/dev_root/projects/xxx/src/server/xxx/s mart_electric_server master ● ll target /xxx-1 .0.0-SNAPSHOT.jar -rwxr--r-- 1 crifan staff 39M 3 27 21:36 target /xxx-1 .0.0-SNAPSHOT.jar |
打包后是39MB,真的不小。
先去mac本地运行试试
1 | target /xxx-1 .0.0-SNAPSHOT.jar |
结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | target / xxx - 1.0 . 0 - SNAPSHOT.jar Logging system failed to initialize using configuration from 'src/main/resources/log4j2.xml' java.io.FileNotFoundException: / Users / crifan / dev / dev_root / projects / xxx / src / server / xxx / xxx / target / src / main / resources / log4j2.xml (No such file or directory) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream. open (FileInputStream.java: 195 ) at java.io.FileInputStream.<init>(FileInputStream.java: 138 ) at java.io.FileInputStream.<init>(FileInputStream.java: 93 ) at sun.net.www.protocol. file .FileURLConnection.connect(FileURLConnection.java: 90 ) at sun.net.www.protocol. file .FileURLConnection.getInputStream(FileURLConnection.java: 188 ) at java.net.URL.openStream(URL.java: 1045 ) at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java: 317 ) at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java: 288 ) at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java: 246 ) at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java: 223 ) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java: 172 ) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java: 165 ) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java: 139 ) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java: 127 ) at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java: 76 ) at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java: 53 ) at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java: 345 ) at org.springframework.boot.SpringApplication.run(SpringApplication.java: 308 ) at org.springframework.boot.SpringApplication.run(SpringApplication.java: 1226 ) at org.springframework.boot.SpringApplication.run(SpringApplication.java: 1215 ) at com.crifan.xxx.AccessingDataMysqlApplication.main(AccessingDataMysqlApplication.java: 12 ) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 62 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 43 ) at java.lang.reflect.Method.invoke(Method.java: 498 ) 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: 51 ) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java: 52 ) 2020 - 03 - 27 21 : 37 : 38 , 278 ERROR SpringApplication.java: 826 - Application run failed java.lang.IllegalStateException: java.io.FileNotFoundException: / Users / crifan / dev / dev_root / projects / xxx / src / server / xxx / xxx / target / src / main / resources / log4j2.xml (No such file or directory) at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java: 324 ) ~[spring - boot - 2.2 . 2.RELEASE .jar! / : 2.2 . 2.RELEASE ] at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java: 288 ) ~[spring - boot - 2.2 . 2.RELEASE .jar! / : 2.2 . 2.RELEASE ] at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java: 246 ) ~[spring - boot - 2.2 . 2.RELEASE .jar! / : 2.2 . 2.RELEASE ] at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java: 223 ) ~[spring - boot - 2.2 . 2.RELEASE .jar! / : 2.2 . 2.RELEASE ] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java: 172 ) ~[spring - context - 5.2 . 2.RELEASE .jar! / : 5.2 . 2.RELEASE ] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java: 165 ) ~[spring - context - 5.2 . 2.RELEASE .jar! / : 5.2 . 2.RELEASE ] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java: 139 ) ~[spring - context - 5.2 . 2.RELEASE .jar! / : 5.2 . 2.RELEASE ] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java: 127 ) ~[spring - context - 5.2 . 2.RELEASE .jar! / : 5.2 . 2.RELEASE ] at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java: 76 ) ~[spring - boot - 2.2 . 2.RELEASE .jar! / : 2.2 . 2.RELEASE ] at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java: 53 ) ~[spring - boot - 2.2 . 2.RELEASE .jar! / : 2.2 . 2.RELEASE ] at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java: 345 ) [spring - boot - 2.2 . 2.RELEASE .jar! / : 2.2 . 2.RELEASE ] at org.springframework.boot.SpringApplication.run(SpringApplication.java: 308 ) [spring - boot - 2.2 . 2.RELEASE .jar! / : 2.2 . 2.RELEASE ] at org.springframework.boot.SpringApplication.run(SpringApplication.java: 1226 ) [spring - boot - 2.2 . 2.RELEASE .jar! / : 2.2 . 2.RELEASE ] at org.springframework.boot.SpringApplication.run(SpringApplication.java: 1215 ) [spring - boot - 2.2 . 2.RELEASE .jar! / : 2.2 . 2.RELEASE ] at com.crifan.xxx.AccessingDataMysqlApplication.main(AccessingDataMysqlApplication.java: 12 ) [classes! / : 1.0 . 0 - SNAPSHOT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?: 1.8 . 0_112 ] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 62 ) ~[?: 1.8 . 0_112 ] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 43 ) ~[?: 1.8 . 0_112 ] at java.lang.reflect.Method.invoke(Method.java: 498 ) ~[?: 1.8 . 0_112 ] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java: 48 ) [xxx - 1.0 . 0 - SNAPSHOT.jar: 1.0 . 0 - SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java: 87 ) [xxx - 1.0 . 0 - SNAPSHOT.jar: 1.0 . 0 - SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java: 51 ) [xxx - 1.0 . 0 - SNAPSHOT.jar: 1.0 . 0 - SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java: 52 ) [xxx - 1.0 . 0 - SNAPSHOT.jar: 1.0 . 0 - SNAPSHOT] Caused by: java.io.FileNotFoundException: / Users / crifan / dev / dev_root / projects / xxx / src / server / xxx / xxx / target / src / main / resources / log4j2.xml (No such file or directory) at java.io.FileInputStream.open0(Native Method) ~[?: 1.8 . 0_112 ] at java.io.FileInputStream. open (FileInputStream.java: 195 ) ~[?: 1.8 . 0_112 ] at java.io.FileInputStream.<init>(FileInputStream.java: 138 ) ~[?: 1.8 . 0_112 ] at java.io.FileInputStream.<init>(FileInputStream.java: 93 ) ~[?: 1.8 . 0_112 ] at sun.net.www.protocol. file .FileURLConnection.connect(FileURLConnection.java: 90 ) ~[?: 1.8 . 0_112 ] at sun.net.www.protocol. file .FileURLConnection.getInputStream(FileURLConnection.java: 188 ) ~[?: 1.8 . 0_112 ] at java.net.URL.openStream(URL.java: 1045 ) ~[?: 1.8 . 0_112 ] at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java: 317 ) ~[spring - boot - 2.2 . 2.RELEASE .jar! / : 2.2 . 2.RELEASE ] ... 22 more |