Apress/pro-spring-5

chapter 2 has a problem with getbean after initial successful build

huntw999 opened this issue · 5 comments

the simple hello world programs have a problem with getbean() this is not available in context after successful build

what can i do to resolve this?

Hello Huntw999,

I am sorry you have problems and happy to take a look.

Can you give me more details? Is the editor complaining about a specific problem?

Cheers!

after download and import into intellij the build works fine no errors

when i try to run anything in any module in intellij it is unable to find the spring classes and some of the supporting classes

main112 would have error when i ran with intellij the class as an application

/Users/williamhunt/All DownLoadsForDevelopment Books/pro-spring-5/chapter06/plain-jdbc/src/main/java/com/apress/prospring5/ch6/PlainJdbcDemo.java
Error:(6, 17) java: package org.slf4j does not exist
Error:(7, 17) java: package org.slf4j does not exist
Error:(15, 20) java: cannot find symbol
symbol: class Logger
location: class com.apress.prospring5.ch6.PlainJdbcDemo
Error:(15, 36) java: cannot find symbol
symbol: variable LoggerFactory
location: class com.apress.prospring5.ch6.PlainJdbcDemo

this error occurred even though the org.slf4j was in the gradle dependency

the help with intellij would as me if i wanted to add to class path which leads me to believe it is not in class path

these errors show up when i create a run application and execute it

after running intellij has trouble finding class it should find

any thoughts?

after import - if i view most classes it will tell me it can't find classes that are in the dependency

Hello William,

In the README.adoc document it is mentioned that you need Gradle 5.x and JDK 8. Considering how old this project is and that is definitely not compatible to Gradle 6, stick to Gradle 5.0.

Make sure IntelliJ knows too that it must compile ad run the project with Java 8 and Gradle 5. Check the Gradle view and configure it to point to the Gradle version you want. And in the IntelliJ menu, go to Project Structure and set Project SDK and Project language Level to 8.

I re-cloned it and build it from scratch, to try to catch any missing libraries.
I've modified the code and added a bunch of @ignore to tests that can't be run without a database or a server. This will allow for the project to fully build and execute most of the tests when doing gradle clean build

master > gradle --version


Gradle 5.0

Build time: 2018-11-26 11:48:43 UTC
Revision: 7fc6e5abf2fc5fe0824aec8a0f5462664dbcd987

Kotlin DSL: 1.0.4
Kotlin: 1.3.10
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_191 (Oracle Corporation 25.191-b12)
OS: Mac OS X 10.15.6 x86_64


master > gradle clean build

This project is a collection of simple code samples. It is meant to be used together with the "Spring Pro, Fifth Edition" published by Apress in order to learn and practice with all Spring Web libraries.

BUILD SUCCESSFUL in 2m 32s
457 actionable tasks: 2 executed, 455 up-to-date

As for the PlainSingerDao the test woud pass if I had a MySQL database locally. Which I don't. And I'm not sure what is wrong with all MySQL docker images, but they all start in --skip-name-resolve mode and ignore my GRANT commands, so I cannot connect to it. And I don't have the time to hunt for a solution for this problem right now.

So, long story short: it works on my computer. Which means the problem is on yours. Check your IntelliJ, there is definitely something wrong with it.

Good luck!
Iuliana

That is very helpful - it gives me the the feedback i need to move it forward thank you