One thing I often read to determine how long a ship is used in Star Trek seems to be hull life, but I think from somewhere in the TNG-era on that's not a problem anymore.
Consider how often Voyager was heavily damaged and in the next episode (maybe a few weeks later?) she was like new. I tend to think they just can repair almost everything with replicators and similar tech, and with that I mean the possibility to manipulate matter on the atomic level. Imagine bending a metal rod so long until it breaks. As I understand it, that's because of the structure of the metal changing. If Starfleet can manipulate the structure of the materials they use, they could repair anything indefinately.
Although I know that in Voyager it probably was just lazy storywriting. ^^