A judge in the US has dismissed actor Justin Baldoni's $400m (£295m) defamation lawsuit against his It Ends With Us co-star Blake Lively.