最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【未解决】把Mac本地的SpringBoot的Java服务部署上传到远程服务器CentOS中

Mac crifan 910浏览 0评论
折腾:
【未解决】Mac本地测试远程服务器中taos报错:java.lang.UnsatisfiedLinkError no taos in java.library.path
期间,先去弄,把Mac的本地的SpringBoot的Java后端服务,上传,部署到远程服务器CentOS7中。
此处对于Java部署一无所知。所以需要慢慢弄。
java spring boot deploy to centos 7
Deploying Spring Boot Applications
然后之前知道的:
mvn clean package
java -jar target/xxx-0.0.1-SNAPSHOT.jar
试试解压jar后有哪些
不过要先去
mvn clean package
打包。
但是发现必须改回mysql的配置:
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/xxx?useUnicode=yes&characterEncoding=UTF-8
spring.datasource.username=xxx
spring.datasource.password=xxx
才能继续重新打包。
且还要先启动mysql
/usr/local/mysql/support-files/mysql.server start
才可以。
生成jar了。去解压试试
jar -xf xxx-1.0.0-SNAPSHOT.jar
输出空的。
好像多出一个文件夹。
但是没注意是哪个。
Deploying Spring Boot Applications
看到:
java org.springframework.boot.loader.JarLauncher
回去一看,好像是org文件夹,果然找到了这个:
试试:
java org.springframework.boot.loader.JarLauncher
结果还报错了:
【未解决】Java的SpringBoot的jar解压后用JarLauncher启动报错:src/main/resources/log4j2.xml No such file or directory
Deploying Spring Boot Applications
Deploying Spring Boot Applications – The Startup – Medium
tomcat – Can I know how to deploy my spring boot application on a centos server……To mention this application worked fine on the localhost – Stack Overflow
Spring Boot应用 打包与部署教程 – Ken的杂谈
java – How do I run a spring boot executable jar in a Production environment? – Stack Overflow
java – Spring Boot Application as a Service linux – Stack Overflow
startup – Spring Boot application as a Service – Stack Overflow
java – How to setup spring-boot to allow access to the webserver from outside IP addresses – Stack Overflow
Spring Boot Tutorial: Build a Spring Boot App and Deploy Into Tomcat – DZone Security
Spring Boot Application as a Service | Baeldung
Spring Boot jar包 Centos7.5 部署的三种方式 sh、service、systemctl – webcreazy的个人页面 – OSCHINA
3. Installing Spring Boot Applications
去加上:
    <configuration>
        <executable>true</executable>
    </configuration>
变成:
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                </configuration>
            </plugin>
        </plugins>
    </build>
去打包
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本地运行试试
target/xxx-1.0.0-SNAPSHOT.jar
结果:
 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

转载请注明:在路上 » 【未解决】把Mac本地的SpringBoot的Java服务部署上传到远程服务器CentOS中

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.190 seconds, using 22.14MB memory