-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is this full source code? #1
Comments
I tried to add this all to the comments of the the tutorial at: https://www.javaguides.net/2022/06/spring-boot-apache-kafka-tutorial.html But it said the content was too long. Maybe someone could edit the tutorial / incorporate the below somehow to help others trying to get the project to work. This is a very useful tutorial and I was grateful to come across it. However, it took me a long time to get it working. Even after I worked through gradle dependency issues, I kept running into the errors 'JDK 17.0.6 isn't compatible with Gradle 7.6.1. Please fix JAVA_HOME environment variable' or - roughly - 'The consumer was configured to find a runtime of a library compatible with Java 12, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6.1' but:' (and the error messages ended like that with nothing after the 'but:'! :-) ) Under Windows 11 (IntelliJ IDEA 2021.2.4 (Community edition), the tutorial does not build / will not work as shown. Maybe it's a little out of date or for a different version of IDEA or only works on Linux or whatever. In any case, I think it could do with a bit more information and clearer instruction. The problems for me were different file syntax, the unclear / misleading instructions and java / SDK version differences; I think it makes a lot of assumptions about prior knowledge or system setup but does not seem to state these assumptions. In case it's helpful to anyone else, I got it working using the following. I had Zookeeper and Kafka already installed and working so I didn't bother with that part of the tutorial and cannot say whether it's accurate or not. I also knew automatically how to adjust the various Zookeeper and Kafka command line tools for Windows vs Linux and the location of my installations so I'm not covering them here either.
dependencies { BUT YOU DON'T CARE ABOUT THAT AT THIS STAGE. Read the rest of this first and hopefully you won't have to come back here.
2.1. Project Structure: Under my installation of IDEA, this meant navigating to File->Project Structure->Project Setting->Project and choosing JDK 17.0.6 from the 'detected SDKs' dropdown. I also chose language level 16 (randomly) but others may work (I didn't experiment). 2.2. 'Gradle JVM': Gradle also needs to be pointed at the correct JDK. For my installation of Intellij IDEA (Windows 11), this meant navigating to File->Settings->Tools->Build, Execution, Deployment->Gradle then in the Gradle JVM dropdown, ensuring JAVA_HOME (for me with version 17.0.6 beside it) was selected.
3.1. First create the following two packages and the net.javaguides.springbootkafka.utils.AppConstant.java (as coded in the tutorial) in your IDEA Gradle project: net.javaguides.springbootkafka.kafka Then go back and follow the tutorial step by step (amending for what you've already done above - I'm going to assume you can handle that yourself), taking note of each case-sensitive class declaration (to know what to call each .java file) and each 'package' statement the author has placed at the top of each class, to know where to put each .java file in your project / package structure. I'm going to assume you already know how to name .java class files and where to put them and why.
4.1. The beginning of Step 2 of the tutorial instructs you to create a Springboot project on the start.springboot.io page (that's where the link redirects to anyway) but this instruction is sparse, misleading and missing some steps. I had a few goes at it before I got it right. Here's a list of steps / things to check that helped me: 4.2. Dependencies: Ok! Here it is! The thing I've already banged on about once or twice at last cleared up! The tutorial gives you a code snippet of some XML dependencies which, if you're a gradle type of person, you might sort of latch on to the idea that they go in your build.gradle file. But they don't. Or, not when or how they're shown anyway. There's nowhere you can add these on the Springboot project generation page and they're not in the right format for build.gradle as I know it (mentioned above) anyway. Instead of typing these in anywhere as the tutorial instructs, you need to do the following: Still on the Springboot page, you need to click the 'ADD DEPENDENCIES' button. The tutorial is not clear on which ones you need to choose; the information is sort of there in the dependencies code snippet (where I deduced it from) but you have to work out the likely 'free text' names of the dependencies from that. The ones I chose (and which got the tutorial working) were: Once you've clicked on each dependency, it will appear listed under the 'ADD DEPENDNCIES' button and the misleading code snippet will be redundant because the dependencies will automatically be added into the build.gradle file (as I showed above) included in the project you are now about to download. 4.3. But now what do you do? The tutorial instructs you to import the project into IDEA. But what do you import into IDEA? And how do you get it on to your computer to import it in the first place? It was obvious enough to me that you had to download something and import it since all these-here IDEs nowadays are just about importing folder structures all the time. But on the Springboot page itself, I had to use my imagination a bit to work out how this might be done. Here are the steps I took: 4.3.1. Once all the settings are correct, click the slightly misleadingly labelled GENERATE button.
|
No description provided.
The text was updated successfully, but these errors were encountered: