Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Sean Smith
Sean Smith
13,797 Points

DatabaseLoader for production app?

Does using the DatabaseLoader to populate a database make sense for an app that will see production? If not, is there a better or more scaleable approach that I should be taking?

1 Answer

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

I think the better way is to have actual database with values, and just read the data properly from it into application.

This way other people that actually create Data for you can fill data elsewhere.

DataLoader is especially nice for testing purposes.

Since Spring Boot 1.4. You can simply annotate it with @TestComponent and this way it will be used only in testing purposes. Thus you don't need to keep temporary databases for Unit Tests.

Sean Smith
Sean Smith
13,797 Points

Thanks, Alexander Nikiforov - this was helpful.

The @TestComponent feature is extremely handy for unit testing. I'm definitely going to use that. As far as the database, what best practice should I follow for getting data into it if I don't use a DatabaseLoader in my application?

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

I think if you are the only one who creates the application, and you have a lot of data to put into app, you can use DataLoader to read file and save it in database using Java.

There is no generic solution for this, I think.

I'm sure that big companies have their databases already filled up, so you just connect them and that is it. I thought that was your question.

If you decided to make a Blog application for example, where you wait for actual users to make blog posts, then may be you can create your blog without a database... I don't know I cannot tell.

Again, depends on the purpose. Can't say anything if I don't know what website you are building ...