Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the situations in which no log is stuck after springboot starts?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces what there is no log stuck after springboot startup, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

1. Scene reproduction

There is no log stuck after the springboot project is started, it must be an error or some other reason, and the log is not printed.

1.1 talk about some common scenarios.

Check to see if exclude has the log package that comes with springboot. After releasing it, there may be a specific reason for the error.

Less common scenarios for org.springframework.boot spring-boot-starter 2.0.5.RELEASE org.springframework.boot spring-boot-starter-logging 1.2

Load it to the place shown below and stop it directly.

Or directly print INFO [class:org.apache.juli.logging.DirectJDKLog | method:log | line:180] logInfo== > Stopping service [Tomcat] without printing specific error information.

It is the log framework used to report specific errors that conflicts with your own project.

1.2.1 apollo forgot to configure

For example, for our project, apollo lacks a key, and the project fails to start directly. It only reports the above error message, but does not report a specific error message.

When apollo is loaded, it is caused by inconsistent logging framework or version. Generally speaking, log4j,slf4j,logback will refer to these, but it is difficult to unify the version, especially other third-party packages.

In the case of apollo, keep version 1.1.1 of commons-logging after conflict resolution, and the error message is printed.

Commons-logging commons-logging 1.1.1

1.2.2 tomcat version conflict

Remove different versions of tomcat dependencies referenced by third parties, leaving only one

Spring-boot-starter-tomcat org.springframework.boot spring-boot-starter-web org.springframework.boot

1.2.3 the package referenced by apollo cannot be found

Can not find the gson package, this is similar to the above, but also failed to load apollo, and then the log printed out, the problem is also easier to find, plus gson dependency.

Caused by: java.util.ServiceConfigurationError: com.ctrip.framework.apollo.internals.Injector: Providercom.ctrip.framework.apollo.internals.DefaultInjector could not be instantiated

At java.util.ServiceLoader.fail (ServiceLoader.java:232)

At java.util.ServiceLoader.access$100 (ServiceLoader.java:185)

At java.util.ServiceLoader$LazyIterator.nextService (ServiceLoader.java:384)

At java.util.ServiceLoader$LazyIterator.next (ServiceLoader.java:404)

At java.util.ServiceLoader$1.next (ServiceLoader.java:480)

At com.ctrip.framework.foundation.internals.ServiceBootstrap.loadFirst (ServiceBootstrap.java:14)

At com.ctrip.framework.apollo.build.ApolloInjector.getInjector (ApolloInjector.java:20)

... 26 common frames omitted

Caused by: com.ctrip.framework.apollo.exceptions.ApolloConfigException: Unable to initialize Guice Injector!

At com.ctrip.framework.apollo.internals.DefaultInjector. (DefaultInjector.java:30)

At sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)

At sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)

At sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)

At java.lang.reflect.Constructor.newInstance (Constructor.java:423)

At java.lang.Class.newInstance (Class.java:442)

At java.util.ServiceLoader$LazyIterator.nextService (ServiceLoader.java:380)

... 30 common frames omitted

Caused by: com.google.common.util.concurrent.ExecutionError: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Lcom/google/gson/Gson

1.2.4 after the project is changed to a packaged lib directory, some of the packages are incomplete.

This problem is the most thorny, looking for a day, because the project jar package is too large, want to separate the jar and the third party is not commonly used package, into jar and lib, you can see this article.

The same pom dependency starts and stops after it is changed to lib

INFO [class:org.apache.juli.logging.DirectJDKLog | method:log | line:180] logInfo== > Stopping service [Tomcat]

We can only compare the original 100m-plus jar decompressed with the new lib directory, and finally find that there is something wrong with the packaging of the third-party package after circular dependency, and the size is not the same. The lib directory only hit its own layer, not cyclically dependent on those packages, resulting in an error when loading.

two。 Summarize the solution ideas and the problem scenarios that arise.

2.1 springboot's own log is excluded, and the tomcat version is inconsistent

2.2 apollo could not find key because the commons-logging version is too high

2.3 No gson package found

2.4 after packaging the lib directory, the package size of the circular dependency is different from that of the single dependency, resulting in some classes missing

If the project is new, try to ensure the compatibility of the third-party packages used when building the project. If it is an old project, when adding a new package, you should pay attention to avoid conflicts as far as possible, and the previous package shall prevail.

Thank you for reading this article carefully. I hope the article "what is the situation of being stuck without a log after springboot startup" shared by the editor will be helpful to everyone? at the same time, I also hope that you will support and pay attention to the industry information channel, and more related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report