This question already has an answer here:
In a Star Destroyer we see people walking around , so there has to be some kind of artificial gravity.
In this question, How does the Death Star gravity work? there is a pretty clear explanation on how gravity is generated on the Death-Star.
What is the explanation of how gravity is generated on a Star Destroyer?