spring-attic / jdbc

Apache License 2.0
11 stars 18 forks source link

Error extending JDBC Source app starter #28

Open morrisdand opened 5 years ago

morrisdand commented 5 years ago

I'm new to this, but I'm having some difficulty extending the JDBC source starter. It's very similar to the example shown in the first link below, and that's the example that I'm following. I'm trying to add the MySQL driver dependency to the JDBC source (I'll be adding Oracle and SQL Server later).

Instructions I'm following are here: https://docs.spring.io/spring-cloud-stream-app-starters/docs/current-SNAPSHOT/reference/htmlsingle/#_patching_pre_built_applications

When I build, I'm receiving an error on the tests that it looks like maven is running on the original source. The error message is as follows:

**_Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2018-10-29 16:35:45.887 ERROR 805 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

Binding to target org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'jdbc' to org.springframework.cloud.stream.app.jdbc.source.JdbcSourceProperties failed:

Property: jdbc.query
Value: null
Reason: must not be null

Action:

Update your application's configuration_**

Again, I'm new to this, so any help would be appreciated. I also have quite a bit more stack trace to share if need be.

Thanks

artembilan commented 5 years ago

How do you build the project? Do you use that ./mvnw clean install -PgenerateApps mentioned in the Docs above?

morrisdand commented 5 years ago

Yes, that's right. I'm in the directory with the pom file and I run the mvnw command that you mention.

artembilan commented 5 years ago

OK. Show, please, Maven logs here including that command.

morrisdand commented 5 years ago

Attached is output from the terminal when I attempt to run "./mvnw clean install -PgenerateApps"

MavenOutput.txt

sabbyanandan commented 5 years ago

Hi, @morrisdand. Sorry that you're having trouble with it. Just so that we understand the problem, you're following the steps described here, in entirety - correct? If yes, is it possible for you to share your Boot app in GitHub?

artembilan commented 5 years ago

Wait that com.morris.JDBCSource.JdbcSourceApplicationTests is something your own. And looks like you don't ensure that jdbc.query property in some of your tests.

Not sure what is your concern to the code here in this project.

And yes: sorry for confuse. You shouldn't use that ./mvnw clean install -PgenerateApps on the custom app.

You should really follow that instruction and download and appropriate app via that https://start-scs.cfapps.io/. Then you modify its POM for appropriate dependency and build exactly a result. You shouldn't modify an original project for app starter.

morrisdand commented 5 years ago

@sabbyanandan - Yes, I used the instructions that you indicate. My project can be found at https://github.com/morrisdand/JDBCSource

@artembilan - I used https://start-scs-cfapps.io/ to generate my project (named com.morris.JDBCSource). I then included the Import annotation that is outlined in the instructions. I then attempted the maven build, which produces the errors indicated in my prior post.

Thanks for your help!

artembilan commented 5 years ago

So, you are good so far!

To test it properly you really need to add entries to the application-test.properties like that required jdbc.query. When you run the test, it instantiates a https://github.com/spring-cloud-stream-app-starters/jdbc/blob/master/spring-cloud-starter-stream-source-jdbc/src/main/java/org/springframework/cloud/stream/app/jdbc/source/JdbcSourceProperties.java and validates what you have provided for it. You can find in that class all the properties you have to specify explicitly.

morrisdand commented 5 years ago

Thank you! I'm working through this now and will update you with my results.