Spain opened their Confederations Cup campaign with an impressive 2-1 victory over Uruguay in Recife.