Giter Club home page Giter Club logo

springit's Introduction

Springit

This is a reddit clone built using Spring Boot 2. I created this project to show off all the cool features of Spring Boot 2.

Getting Started

TODO: How to get started?

Prerequisites

TODO: What do they need to get started

Installing

TODO: Installing

Running the tests

Explain how to run the automated tests for this system

Break down into end to end tests

Explain what these tests test and why

Give an example

And coding style tests

Explain what these tests test and why

Give an example

Deployment

Add additional notes about how to deploy this on a live system

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Thank you PurpleBooth for the README template.
  • Thank you to the Spring Boot team for the awesome software!

springit's People

Contributors

danvega avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

springit's Issues

Link conversion error upon submission of a new comment

This issue relates to lecture 76, adding a new comment.

When executing the "Post" operation, upon submission of a new comment, the Link field (as part of the Comment Object) cannot be converted to an actual Link and therefore comes back null (thus with Binding errors).

The error shown upon debugging is something like "org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'comment' on field 'link': rejected value [com.kosmas.springit.domain.Link@49c33fdc];....no matching editors or conversion strategy found)

My solution was to

  1. Define a Link converter class from String to Link
  2. Override the ToString method in Link to return simply a string of the id.

In combination, the two changes result in the Link object being converted appropriately. Not sure if this is the best way to solve this, so happy to hear any alternative solutions.

This is the code for the Link Converter class.

package com.kosmas.springit.converter;

import com.kosmas.springit.domain.Link;
import com.kosmas.springit.repository.LinkRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class LinkByIdConverter implements Converter<String, Link> {

    private LinkRepository linkRepository;

    @Autowired
    public LinkByIdConverter(LinkRepository linkRepository) {
        this.linkRepository = linkRepository;
    }

    @Override
    public Link convert(String id) {
        return linkRepository.getOne(Long.parseLong(id));
    }

}

User is not set on a new Link entity

Current user should be set on a newly created Link entity.
This is done manually in the DatabaseLoader, but it's not done when the link is created through the UI.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.