The fleeing people are just a symptom. We could rescue people in the Mediterranean and grant them citizenship till there was no room left, and people would still try to cross it as long as the causes are still active.

Which is to say that the war in Syria needs to be stopped in a way that it does not flare up again 20 years later (hint to the fans of arab dictators), the Eritrean leadership (or at least its policies) need to be changed and Somalia needs to be fixed. Do these things, and much of the migrant masses would already have disappeared.