I have a Spring REST application, and I'm thinking about what type of security to use. I'm considering between two options:
It must be good and secure enough for nowadays. Application is going to be a simple service or few small services. As a database I'm using MongoDB (probably it doesn't matter).
Maybe someone has some pros and cons of each type or any other suggestions what to use.
First of all , your both points are same and point # 2 is incorrect as JWT is only a token format and not the actual security mechanism so both can't be compared.
OAuth2 server is the one which will generate token for you either in JWT or non-JWT format , that is your choice.
I am not sure about all the technologies out there but if you go by popularity, an OAuth2 as Authorization Server and JWT as token format are quite popular.
Application / API Security means lots of things and Authentication plus Authorization prevents lots of attacks. Obviously, not everything is a developer concern and most goes to infrastructure or security teams.