Science fiction is full of spaceships zipping around the galaxy, and almost all of them seem to have some kind of artificial gravity on board. For TV shows and movies, this is obviously a practical necessity, and even for written science fiction, freefall is such an alien condition that it would be a real challenge to write realistically about it. So science-fictional spaceships generally have some sort of artificial gravity. But will real spaceships?
Current spacecraft certainly don't have any kind of artificial gravity. Early craft, like the Mercury, or Apollo, were so cramped I think it must have been a blessing to be able to use every available cubic centimeter. Soyuz, still in use, is not much bigger, and the Space Shuttle is mighty cramped too. In any case, when people are spending only a few days at a time in an environment, they can put up with a great deal. But in the longer term, it does appear that freefall may cause some health issues: even with two hours of exercise a day, astronauts seem to suffer from bone demineralization, muscle loss, and cardiovascular problems, and there also seem to be some peculiar immune system effects (though apparently cockroaches adapt just fine). For the International Space Station, astronauts exercise and don't stay up too long. But for something like a mission to Mars, it would certainly be nice to provide some sort of artificial gravity.
Shows like Star Trek and Battlestar Galactica posit some kind of "gravity generator", but this is pretty much the same technology as antigravity (and maybe reactionless drives). This basically requires wild departures from the laws of physics as we know them, so I'll leave them and other "magic" systems aside.
We do know one way to produce something very like gravity: rotation. If you're in a wheel that's spinning, centrifugal force feels very like gravity, pushing you outwards against the wall. There is the Coriolis force, which gives moving objects a push at right angles to their direction of motion; it turns out that if you spin humans at more than about 10 revolutions per minute and they try to move around, the Coriolis force causes severe disorientation and nausea. But with a wheel of 20 m diameter you can get a full Earth gravity by rotating at that top speed. (Incidentally, that 10 RPM is with slow and careful acclimatization, so it would be preferable to limit it to 3 RPM or less, to which most people can become acclimatized; that triples the needed diameter.)
Science fiction contains a number of examples of spaceships with rotating sections. This doesn't violate any laws of physics, but it seems to me to present some rather serious engineering difficulties. The first is, how do you connect the rotating section to the non-rotating section? I can imagine some rolling ball-bearing joint, though the vacuum of space does tend to make things stick together, and rolling joints generally require constant lubrication (and frequent maintenance), which is going to be hard to do in a vacuum. There's also the issue that, given the size of the moving parts, if there's any kind of problem with the joint, the ship will probably tear itself apart.
If you want people to be able to easily move back and forth between the sections, you'll need to pressurize the whole thing, which means that you need this rolling joint to also be airtight. Techniques for making rolling seals range from the simple to the exotic (stuffing boxes, labyrinth seals, ferrofluid seals) but they're all tricky, and for the kind of long-term operation that motivates artificial gravity, you would need exceedingly low leakage and very high reliability. You could avoid this, and vacuum joint issues, by having a spinning wheel inside a non-spinning airtight shell, but mass will always be at a premium, and remember the wheel has to be quite large.
More serious as a problem, it seems to me, is the issue of cable wrapping. Think of it this way: how do you connect the cables and hoses - power, communications, air, water - from the rotating segment to the stationary segment? If you just connect them directly, they will immediately get twisted into a bundle and then break (radio telescopes solve this problem by having only a limited range of rotation - 720 degrees for Arecibo, for example - but this is obviously no use here). In principle you could do something with a ring on one part of the ship and a brush that slides around it on the other, but remember you have to have a separate ring for every connection you want to make, and this sort of sliding connection is one of the trickiest parts of an electric motor to build. If you were feeling particularly devious you could transmit power to the rolling part of the ship by using a generator to draw power from the rotation itself, and if you had to you could avoid other electrical connections by transmitting all your data (control, telemetry, navigation, et cetera) wirelessly from one part of the ship to the other. Water hoses are going to be a problem any way you cut it.
I think my preferred solution is to roll the whole ship. This does make it a pain to do things like fix a telescope on one point, or keep your communications dish pointed at the Earth, but for a ship that moves around all your exterior sensors need to be steerable anyway, so this doesn't seem like it is necessarily a problem.
Whether you roll the whole ship or just have a rotating section, the angular momentum bound up in the rolling section will make maneuvering the ship a nightmare. Not impossible, especially under computer control, but expensive in terms of fuel, liable to cause tumbling, and just generally a bad idea. So stopping the rotation when you need to maneuver seems sensible; maneuvers will probably be rare and planned well in advance. This does mean you need a not-too-expensive way to start and stop the rotation. A pair of counterrotating sections, or a flywheel, would let you do it without using up any reaction mass, just energy, but there's a very great deal of angular momentum to store, so it may be easier to simply use maneuvering jets.
For a space station, many of the same issues apply; rolling the whole station still seems like the simplest and most reliable approach. The cost of starting and stopping isn't very important, since presumably the station will be spun up once built and keep spinning indefinitely. Docking with such a station might be a challenge, though. Docking at the rim requires spacecraft to essentially "hover" under a gravity of thrust before they can latch on. Docking at or near the hub could be done by just matching the ship's roll to the station. Unloading would then have to take place in microgravity (though with the Coriolis force). Ships, once docked, would presumably be moved to berths off the station's axis to make room for more landings. Departures should probably be along the axis as well for the sake of station stability, although in principle a ship could just "drop" off the station rim at the right moment and steal a nice initial kick from station rotation. Whether or not ships do this, the station will need to be able to shift substantial amounts of mass around its rim to keep itself balanced; large movements of mass aboard station will need to be arranged ahead of time with station control.
In summary, artificial gravity is possible and probably desirable for long-term stays in space, but it won't be simple.