In this post, I will demonstrate how to resolve the following error when running spring cloud eureka server:
The key problem is below:
2. The solution
The detailed error
I want to start an spring cloud eureka server in IntelliJ IDEA, but I got this error:
The module’s dependency
The source code
The Eureka Server’s source code:
The parent module’s dependency:
This module’s dependency:
if start from command line, we got this error:
Let’s Debug the error
Check the java version:
The solution
Run the following command in parent module:
Then re-run the module:
But double-clicking the run to run the spring-boot plugin in the idea still reports an error:
The reason of the error
Idea use jdk 1.6 to start spring applicaiton, just as the logs show:
Then I check:
It’s jdk1.6, NOT jdk1.8, that is the problem.
Change project sdk to 1.8:
Then click ‘spring-boot:run’ to run again:
It works!
How to change default JAVA sdk version for new java projects?
Click File--Other Settings--Structure for new projects:
then change default sdk for intellij idea:
3. Summary
In this post, I demonstrated how to solve the module java.base does not "opens java.lang" to unnamed module error. The key point is to make sure that your java version is correct. That’s it, thanks for your reading.
Final Words + More Resources
My intention with this article was to help others who might be considering solving such a problem.
So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by
email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
When we build spring boot applications with gradle, sometimes we get this error :
Environments
The environments are as follows:
java version: jdk 1.8+
spring boot version: 2.3.2.RELEASE+
The build.gradle
The build.gradle of this spring boot application is as follows:
How to resolve the problem
This error is caused by the incorrectly configured build.gradle in the project. You should add buildscript block to the build.gradle, this buildscript block is required by the build.gradle script.
After the above change, the whole build.gradle file is as follows:
More about BuildScript
The buildscript block in a build.gradle file is used to configure the build script itself. It allows you to define dependencies and repositories that are needed for the build script to run. This is different from the dependencies and repositories that are needed for the project being built.
Here is an example of a buildscript block:
In this example:
The repositories block specifies where to find the dependencies needed for the build script. In this case, it is using Maven Central.
The dependencies block specifies the dependencies needed for the build script. Here, it includes the Android Gradle plugin.
This configuration is necessary for setting up the environment in which the build script will execute.
The code base of this example is uploaded to github.com, you can click this web url to download the code.
Final Words + More Resources
My intention with this article was to help others who might be considering solving such a problem.
So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by
email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
to verity the installation, but sometimes we would get this error:
2. Environments
The linux system is:
3. Debug
We try to find the file named libssl.so.1.1 as follows:
We can find that the libcrypto.so.1.1 is located in the /usr/local/lib64,
But openssl try to find the .so libraries in the LD_LIBRARY_PATH:
So the solution is try to tell openssl where the library is.
4. Resolve it
There are two methods to resolve this problem:
4.1 Method 1: Change the LD_LIBRARY_PATH
4.2 Method 2: Create a link to the file
5. More about the LD_LIBRARY_PATH
As the linux documents shown:
Final Words + More Resources
My intention with this article was to help others who might be considering solving such a problem.
So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by
email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
When our app change the target to android sdk 31 or android 12, the app crash and we get this error message:
The key error message is:
2. Reason
Since Android 12 brought important updates to PendingIntents, including the need to explicitly determine if a PendingIntent is mutable, I thought it was worth talking in-depth about what a PendingIntent does, how the system uses it, and why you might need mutable types PendingIntent.
What is pending intent?
Let’s look at the different ways PendingIntents are used in applications, and why we use them.
Basic usage of pending intent:
You can see that we built a standard type of Intent to open our app, and then simply wrapped it with a PendingIntent before adding it to the notification.
In this example, we constructed a PendingIntent that cannot be modified with the FLAG_IMMUTABLE flag because we know exactly what we need to do in the future.
The job is done after calling NotificationManagerCompat.notify(). When the system displays a notification, and the user clicks on the notification, PendingIntent.send() is called on our PendingIntent to start our application.
How to update the immutable pending intent?
You might think that if the application needs to update the PendingIntent, it needs to be a mutable type, but it’s NOT. The PendingIntent created by the application can be updated with the FLAG_UPDATE_CURRENT flag.
3. Solution
So, the final solution is as below:
change from this :
to this:
4. Summary
In this post, I demonstrated how to solve the Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent problem when your android app change target sdk to 31 and above, the key point is adding a PendingIntent.FLAG_IMMUTABLE flag to your PendingIntent. That’s it, thanks for your reading.
Final Words + More Resources
My intention with this article was to help others who might be considering solving such a problem.
So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by
email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
This post will demo how to resolve the IllegalArgumentException:Could not resolve placeholder exception when using @Value in Spring app or Spring Boot apps.
2. Environments
Spring Boot
3. The Exception
When we use @Value like this:
However, most importantly, if there is no myProp property in sysconfig.properties, we will get this exception:
The key error message Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'myProp' in value "${myProp}"
indicated that there is no property named myProp in the custom properties file named sysconfig.properties.
4. How to fix it
4.1 Way 1: Add the property key to your properties file
4.2 Way 2: Provide a default value for the property
If you don’t want to provide the key in your file, you can just set @Value’s default value:
You can change the defaultValue to your real default value.
4.3 Way 3: Provide an empty default value for the property
If you want to provide an empty default value, just do like this:
Notice the myProp: , the colon is important.
Just leave empty after the colon, then you would get an empty default value for property myProp.
5. Summary
You can see that @Value must be used carefully, if you get the above exceptions ,just provide the default values of the @Value.
Final Words + More Resources
My intention with this article was to help others who might be considering solving such a problem.
So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by
email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope: